Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Help with activating previous sheet


Hello, I am having trouble making Excel activate the previous workbook.

We have a program which automatically creates spreadsheets in Excel
(With random names) so I cannot just do a
workbook("Book1.xls").activate code.

I am looking for a way to say "Go back to the last workbook you were
in".

Is this possible??

Thanks

John C


--
johncassell
------------------------------------------------------------------------
johncassell's Profile: http://www.excelforum.com/member.php...o&userid=25016
View this thread: http://www.excelforum.com/showthread...hreadid=540647

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default Help with activating previous sheet

If the process is controlled by code you could do something like this:
In header:
Public LastBookUsed as Workbook
In your sub:
Set LastBookUsed = Workbooks.Add
....
LastBookUsed.Activate
But this would only work in certain situations where your code is in
control; if the user freely switches workbooks you need to trap that as an
event in order to keep track of which book was last used. The Excel
Application has a WorkbookActivate event but I think you would need to create
a class With Events in order to trap the event and create an event procedure
that would keep track of the last workbook the user was in.
--
- K Dales


"johncassell" wrote:


Hello, I am having trouble making Excel activate the previous workbook.

We have a program which automatically creates spreadsheets in Excel
(With random names) so I cannot just do a
workbook("Book1.xls").activate code.

I am looking for a way to say "Go back to the last workbook you were
in".

Is this possible??

Thanks

John C


--
johncassell
------------------------------------------------------------------------
johncassell's Profile: http://www.excelforum.com/member.php...o&userid=25016
View this thread: http://www.excelforum.com/showthread...hreadid=540647


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
autorun upon activating a sheet cdde[_6_] Excel Programming 0 November 10th 04 11:43 PM
autorun upon activating a sheet cdde[_5_] Excel Programming 1 November 10th 04 07:34 PM
Error 40036 when activating a sheet shinydiamond Excel Programming 5 February 11th 04 10:11 PM
Problem activating a sheet jowatkins[_6_] Excel Programming 1 January 19th 04 01:33 PM
Problem in activating a sheet Neeleshwar Thakur Excel Programming 1 December 18th 03 12:43 PM


All times are GMT +1. The time now is 04:51 PM.

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"