Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Referencing workbooks in macros

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default Referencing workbooks in macros

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Referencing Other Workbooks Rick B Excel Discussion (Misc queries) 3 May 15th 06 04:14 PM
Referencing other workbooks augustus Excel Worksheet Functions 1 March 8th 06 06:07 AM
Referencing workbooks Ken New Users to Excel 1 December 31st 04 04:45 PM
referencing different workbooks jimmy[_4_] Excel Programming 1 November 15th 03 02:54 PM
Referencing other workbooks Stuart[_9_] Excel Programming 2 October 29th 03 11:31 PM


All times are GMT +1. The time now is 03:52 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"