Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi All,
I havent worked with opening and closing workbooks from excel macros for a while and seem to recall a neat little routine to capture whether a workbook was open or not, if not it opens it, if open, it continues the macro. Can someone assist with code to this affect or point me in the direction of a helpful site. Thanks. Neil |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Neil,
There may be better ways but this works. Sub Macro1() On Error GoTo openWorkbook Windows("Book3").Activate On Error GoTo 0 MsgBox "Your code after workbook is activated goes here" GoTo skipOpenWB 'skip the open work book code when 'procedure completes. End also works. openWorkbook: Workbooks.Open Filename:= _ "C:\Users\Peter\Documents\Excel\Test Macros\Book3.xlsm" MsgBox "Workbook had to be opened" Resume Next skipOpenWB: End Sub Regards, OssieMac "Neil" wrote: Hi All, I havent worked with opening and closing workbooks from excel macros for a while and seem to recall a neat little routine to capture whether a workbook was open or not, if not it opens it, if open, it continues the macro. Can someone assist with code to this affect or point me in the direction of a helpful site. Thanks. Neil |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Referencing Other Workbooks | Excel Discussion (Misc queries) | |||
Referencing other workbooks | Excel Worksheet Functions | |||
Referencing workbooks | New Users to Excel | |||
referencing different workbooks | Excel Programming | |||
Referencing other workbooks | Excel Programming |