Check for open workbook

  • Thread starter Thread starter georgio
  • Start date Start date
G

georgio

howdy all
this should be relatively simple, i'm just not sure how to do it

i have 2 workbooks A.xls and B.xls

when i open A.xls, i want it to check and see if B.xls is open
if B.xls is open, then do nothing
if B.xls is not open, then open B.xls

that's it
i'm just not sure how to set the code to do it
any help would be great :)
thank
 
On Error Resume Next
Set oWB2 = Workbooks("B.xls")
On Error GoTo 0
If oWB2 Is Nothing Then
MsgBox "Open workbook 2"
End If


--

HTH

RP
(remove nothere from the email address if mailing direct)
 
I often open multiple workbooks by "referencing" them to the master workbook.

Open excel, go to macro and select VBA to open the VBA editor.

Then go to tools and click references and browse to your files.
 
Back
Top