Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default 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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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/

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
macro to find cell content in sheets and make sheet active Nigel Excel Discussion (Misc queries) 4 June 26th 14 02:38 PM
Run macro when Sheets are active Ed Davis[_2_] Excel Discussion (Misc queries) 2 October 1st 09 04:54 PM
Selecting Embedded charts in Active Sheets programmatically Barb Reinhardt Charts and Charting in Excel 5 January 15th 06 02:36 PM
In 3 active sheets in wkbk, determine& display the # of sheets that have data wrpalmer Excel Discussion (Misc queries) 1 November 4th 05 02:01 PM
HOW TO COPY 480 ACTIVE E-MAIL ADDRESSES CLM "G" ON AN ACTIVE EXCE. ragman10 Excel Discussion (Misc queries) 1 December 13th 04 11:52 PM


All times are GMT +1. The time now is 02:57 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"