ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How do I make an open workbook the active workbook (https://www.excelbanter.com/excel-programming/286496-re-how-do-i-make-open-workbook-active-workbook.html)

Don Guillett[_4_]

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





All times are GMT +1. The time now is 10:50 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com