I have a simple question (I think). Let's say I set a global variable in a standard module in Book1 to an open (different) workbook:
Public Sub InitGlobals()
Set gwkb = Workbooks("book2.xlsx")
End Sub
Now I close book2.xlsx manually. What is the status of gwkb
? This is what I get when I run various tests in the immediate window:
?gwkb is nothing
False
?isempty(gwkb)
False
?isnull(gwkb)
False
However, if I ask for any property of gwkb
, such as gwkb.Name
, I get an automation error.
My question is: is there a way to test for this condition, without resorting to some sort of "On Error Resume Next
" test?
Thanks for your help.