open already opened file

  • Thread starter Thread starter Nico
  • Start date Start date
N

Nico

Hi,

I have some VBA-code that opens an Excel-workbook. But when that workbook is
already open, I want this action to be aborted and set my workbook variable
to the existing opened workbook. Anyone know how to do this?

Kind regards,
Nico.
 
One way:

Dim wb As Workbook
On Error Resume Next
Set wb = Workbooks("MyBook.xls")
On Error GoTo 0
If wb Is Nothing Then _
Set wb = Workbooks.Open ...
 
Back
Top