Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default open workbook from a macro and continue this macro afterwards

I launch a second workbook from within a macro. This macro must stop
executing until the second workbook is closed again.
Version is Excel 2002.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default open workbook from a macro and continue this macro afterwards

Hi Chris,

Try putting the instruction to open the second workbook in one procedure,
e.g:

'=============
Public Sub Tester1()
Workbooks.Open Filename:="Workbook2.xls"
End Sub
'<<=============

Then put the remaining instructions in the second workbook's close event
code, e.g.:

'=============
Private Sub Workbook_BeforeClose(Cancel As Boolean)
'Code to run when Workbook2 closes
End Sub
'<<=============

---
Regards,
Norman


"Chris De Luyck" <Chris De wrote in message
...
I launch a second workbook from within a macro. This macro must stop
executing until the second workbook is closed again.
Version is Excel 2002.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 139
Default open workbook from a macro and continue this macro afterwards

Hi:

try Do While ...Loop statement ,

Dim wbk As Workbook
Sub test()
Set wbk = Workbooks.Add
On Error GoTo ErrorHandler
Do While TypeName(wbk) = "Workbook"
'your code
'..............
DoEvents
Loop
MsgBox "Workbooks is close"
ErrorHandler:
Set wbk = Nothing
End Sub

--
天行健,君*以自強不息
地勢坤,君*以厚德載物

http://www.vba.com.tw/plog/


"Chris De Luyck" wrote:

I launch a second workbook from within a macro. This macro must stop
executing until the second workbook is closed again.
Version is Excel 2002.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default open workbook from a macro and continue this macro afterwards

Another option is to issue a scheduled macro, using OnTime, to check if the
workbook is open, if so, reissue it again for a later time, if not, the rest
of your code..

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"chijanzen" wrote in message
...
Hi:

try Do While ...Loop statement ,

Dim wbk As Workbook
Sub test()
Set wbk = Workbooks.Add
On Error GoTo ErrorHandler
Do While TypeName(wbk) = "Workbook"
'your code
'..............
DoEvents
Loop
MsgBox "Workbooks is close"
ErrorHandler:
Set wbk = Nothing
End Sub

--
???,???????
???,???????

http://www.vba.com.tw/plog/


"Chris De Luyck" wrote:

I launch a second workbook from within a macro. This macro must stop
executing until the second workbook is closed again.
Version is Excel 2002.



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
Can a macro be paused to allow input, then continue? Rufushenry Excel Worksheet Functions 2 December 31st 09 07:01 PM
VB code to continue macro Brian Excel Discussion (Misc queries) 3 May 9th 06 03:12 AM
VBA codes for macro to continue Brian Excel Programming 11 May 23rd 05 11:33 PM
The way to continue do macro recording Susan Soo[_2_] Excel Programming 2 February 16th 05 03:21 PM
Pause macro, add form button to sheet, continue macro when button clicked! Flystar[_15_] Excel Programming 1 May 26th 04 09:45 AM


All times are GMT +1. The time now is 09:21 AM.

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"