View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Don Guillett[_4_] Don Guillett[_4_] is offline
external usenet poster
 
Posts: 2,337
Default How do I make an open workbook the active workbook

Looking at the code provided it appears that you want to open if closed or
activate if not the active workbook.

Sub ActivateMyWorkbook() 'from MS
On Error GoTo ErrorHandler
Workbooks("Book2.xls").Activate
'The following line will halt the macro before the error handler
'is reached.
Exit Sub
ErrorHandler:
Workbooks.Open FileName:="Book2.xls"
End Sub

--
Don Guillett
SalesAid Software

wrote in message
...
I have a workbook that is open, and would like to make it the active
workbook. I tried this code, but it does not work. Can anyone tell
me how to do this?

If (Not UtilitiesWorkbookIsOpen("myWorkbook.xls")) Then
MsgBox "Please open myWorkbook.xls"
Exit Sub
Else
ThisWorkbook.Activate
End If