If Not Open, Open File - VBA

dnorm

Board Regular
Joined
Dec 28, 2017
Messages
79
Hi All

I am after a check/open file VBA. I can create a macro to open/close a file (cheers Guys who helped (y) ), now would like to add a check too.
If FILE A is open, continue, if NOT open FILE A... type of thing.

Thank you all!
 

Some videos you may like

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
42,721
Office Version
365
Platform
Windows
Something like
Code:
   Dim Wbk As Workbook
   
   On Error Resume Next
      Set Wbk = Workbooks("Book1.xlsm")
   On Error GoTo 0
   If Wbk Is Nothing Then
      set wbk=workbooks.Open(..)
   End If
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
42,721
Office Version
365
Platform
Windows

Watch MrExcel Video

Forum statistics

Threads
1,102,453
Messages
5,486,993
Members
407,575
Latest member
calc

This Week's Hot Topics

Top