View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Opening a workbook if not opened, going to it if already opened

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.

--
Regards,
Tom Ogilvy

"neotokyo" wrote in message
...

Your code works great...just one problem.
When the workbook file is already open, the code makes the workbook
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 leaves
it on(without closing and then re-opening).


Thanks


--
neotokyo
------------------------------------------------------------------------
neotokyo's Profile:

http://www.excelforum.com/member.php...o&userid=13892
View this thread: http://www.excelforum.com/showthread...hreadid=263271