Opening a workbook if not opened, going to it if already opened

  • Thread starter Thread starter neotokyo
  • Start date Start date
N

neotokyo

Your code works great...just one problem.
When the workbook file is already open, the code makes the workboo
re-open(thus asking me if I want to save changes).
How can I change the code so that if its already open, it just leave
it on(without closing and then re-opening).


Thank
 
No, my code doesn't do that.

Apparently you have screwed it up.

My code is tested and works fine:

Sub BBB()
Dim wkbk As Workbook
On Error Resume Next
Set wkbk = Workbooks("ABC.xls")
On Error GoTo 0
If wkbk Is Nothing Then
Set wkbk = Workbooks.Open("C:\Myfiles\ABC.xls")
End If
wkbk.Activate
End Sub


did you change the name from ABC.xls and C:\MyFiles\ABC.xls to the name/path
and name of your workbook - perhaps you have misspelled the name.
 

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