![]() |
Active sheets
Hello all,
I have a macro that opens a second work book, does various things and then closes the second workbook. Once closed does the existing workbook automatically become the active workbook again as it is the only one now open? It would seem i have to activate it again by specifying its name, i'd like to avoid this if possible. Any help appreciated. Cheers Joe |
Active sheets
Hi Joe
I would suggest you add the following coede to your macro: sub foo() Dim old_wbk as workbook Dim old_wks as worksheet Set old_wbk = Activeworkbook Set old_wks = old_wbk.Activesheet '....your code old_wbk.activate old_wks.activate end sub -- Regards Frank Kabel Frankfurt, Germany Joe Bannister wrote: Hello all, I have a macro that opens a second work book, does various things and then closes the second workbook. Once closed does the existing workbook automatically become the active workbook again as it is the only one now open? It would seem i have to activate it again by specifying its name, i'd like to avoid this if possible. Any help appreciated. Cheers Joe |
Active sheets
Heartily endorse this approach. By creating object variables you don't need
to worry about what is active, just refer to the object through that variable. -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Frank Kabel" wrote in message ... Hi Joe I would suggest you add the following coede to your macro: sub foo() Dim old_wbk as workbook Dim old_wks as worksheet Set old_wbk = Activeworkbook Set old_wks = old_wbk.Activesheet '....your code old_wbk.activate old_wks.activate end sub -- Regards Frank Kabel Frankfurt, Germany Joe Bannister wrote: Hello all, I have a macro that opens a second work book, does various things and then closes the second workbook. Once closed does the existing workbook automatically become the active workbook again as it is the only one now open? It would seem i have to activate it again by specifying its name, i'd like to avoid this if possible. Any help appreciated. Cheers Joe |
Active sheets
I would say the old workbook automatically becomes the active workbook.
At least in this example: ActiveWorkbook.close True, SPECName In this case active workbook (new workbook) is closed and changes are saved as SPECName, and the old workbook becomes the active workbook. --- Message posted from http://www.ExcelForum.com/ |
All times are GMT +1. The time now is 12:46 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com