Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 389
Default Go to Last Active Window

I have a macro that opens a file and then goes to that file making it the
active window. I then want to go back to the previous file but not tuse the
name of the file because the file it goes back to can be any file (ie it will
not always be the same file.) How do you programmatically go to the last
window open without using the file name.

Thank you,

Steven
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Go to Last Active Window

If #I follow what you mean, include something like the following in your
macro

Dim wb as Workbook

Set wb = Activeworkbook ' maintain a ref' to the original workbook

' workbooks.open filename

' make the orignal workbook active
wb.Activate

Regards,
Peter T



"Steven" wrote in message
...
I have a macro that opens a file and then goes to that file making it the
active window. I then want to go back to the previous file but not tuse

the
name of the file because the file it goes back to can be any file (ie it

will
not always be the same file.) How do you programmatically go to the last
window open without using the file name.

Thank you,

Steven



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Go to Last Active Window

So just to be clear you have 3 files to deal with. The one that is running
the code. Another one that is active and finally a new one that you are
opening/selecting?
--
HTH...

Jim Thomlinson


"Steven" wrote:

I have a macro that opens a file and then goes to that file making it the
active window. I then want to go back to the previous file but not tuse the
name of the file because the file it goes back to can be any file (ie it will
not always be the same file.) How do you programmatically go to the last
window open without using the file name.

Thank you,

Steven

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Go to Last Active Window

It depends on how you "go to" that file. Say we have Book1 and Book2 open
with Book1 being active. This macro:

Sub gothere()
Application.Goto
Reference:=Workbooks("Book2").Worksheets("Sheet1") .Range("A154")
End Sub

will "goto" a specific place in Book2. Now lets say we want to return, but
have not remembered where we came from. We just want to go back. All we
need to do is:

Sub goback()
Application.Goto
End Sub

Excel keeps a stack of the places we visit if we have a chain of "gotos".

Application.Goto
without an argument is like the back arrow in IE.
--
Gary''s Student - gsnu200772


"Steven" wrote:

I have a macro that opens a file and then goes to that file making it the
active window. I then want to go back to the previous file but not tuse the
name of the file because the file it goes back to can be any file (ie it will
not always be the same file.) How do you programmatically go to the last
window open without using the file name.

Thank you,

Steven

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 389
Default Go to Last Active Window

And we have a winner. Thank you very much.

"Peter T" wrote:

If #I follow what you mean, include something like the following in your
macro

Dim wb as Workbook

Set wb = Activeworkbook ' maintain a ref' to the original workbook

' workbooks.open filename

' make the orignal workbook active
wb.Activate

Regards,
Peter T



"Steven" wrote in message
...
I have a macro that opens a file and then goes to that file making it the
active window. I then want to go back to the previous file but not tuse

the
name of the file because the file it goes back to can be any file (ie it

will
not always be the same file.) How do you programmatically go to the last
window open without using the file name.

Thank you,

Steven




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
how to set workbook window active Daniel M Excel Programming 1 November 26th 07 04:34 AM
How to Active Window maperalia Excel Programming 5 July 13th 07 03:56 PM
Re-size active window blackbox via OfficeKB.com Excel Programming 2 June 19th 07 10:20 AM
Active Window Question CWillis Excel Discussion (Misc queries) 4 July 19th 06 05:52 PM
active window Gerry Excel Programming 2 December 17th 04 03:33 PM


All times are GMT +1. The time now is 05:48 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"