![]() |
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. |
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. |
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. |
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. |
All times are GMT +1. The time now is 12:10 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com