Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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/ |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
macro to find cell content in sheets and make sheet active | Excel Discussion (Misc queries) | |||
Run macro when Sheets are active | Excel Discussion (Misc queries) | |||
Selecting Embedded charts in Active Sheets programmatically | Charts and Charting in Excel | |||
In 3 active sheets in wkbk, determine& display the # of sheets that have data | Excel Discussion (Misc queries) | |||
HOW TO COPY 480 ACTIVE E-MAIL ADDRESSES CLM "G" ON AN ACTIVE EXCE. | Excel Discussion (Misc queries) |