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 ...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top