Greetings, and apologies if I missed a previous discussion of this topic.
Excel2003. VBA.
I have a set of workbooks, any of which may be opened at any time from a master workbook. One of them has to be open only during certain functions, and then must be closed. This can happen 2 or 3 times during a run, and it is not set in stone that the open or closed status happens in a particular order.
So, I have been trying to develop a few lines of code that will check to see if the workbook is open. If not, it would then open it; if so, it would simply move on.
I have used:
If Windows("MyWKBK").Visible = False then
Workbooks.Open("C:\MyWKBK")
End If
and
If Workbooks("MyWKBK").IsInplace = False then
Workbooks.Open("C:\MyWKBK")
End If
and
If Workbooks("C:\MyWKBK").IsInplace = False then
Workbooks.Open("C:\MyWKBK")
End If
and
If Workbooks("C:\MyWKBK").Windows.Visible = False then
Workbooks.Open("C:\MyWKBK")
End If
but none of them work. The usual error is "Subscript out of range" meaning it can't see the object, but that's the point. If it can't see the object, I want it to open the object.
I'm missing something obvious I'm sure, but I cannot say what.
Thank you in advance for your wisdom and patience.
Excel2003. VBA.
I have a set of workbooks, any of which may be opened at any time from a master workbook. One of them has to be open only during certain functions, and then must be closed. This can happen 2 or 3 times during a run, and it is not set in stone that the open or closed status happens in a particular order.
So, I have been trying to develop a few lines of code that will check to see if the workbook is open. If not, it would then open it; if so, it would simply move on.
I have used:
If Windows("MyWKBK").Visible = False then
Workbooks.Open("C:\MyWKBK")
End If
and
If Workbooks("MyWKBK").IsInplace = False then
Workbooks.Open("C:\MyWKBK")
End If
and
If Workbooks("C:\MyWKBK").IsInplace = False then
Workbooks.Open("C:\MyWKBK")
End If
and
If Workbooks("C:\MyWKBK").Windows.Visible = False then
Workbooks.Open("C:\MyWKBK")
End If
but none of them work. The usual error is "Subscript out of range" meaning it can't see the object, but that's the point. If it can't see the object, I want it to open the object.
I'm missing something obvious I'm sure, but I cannot say what.
Thank you in advance for your wisdom and patience.