Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 56
Default Go back to the previous excel file

I have the following macro that works great:
Sub OpenData()
ChDir "Y:\somewhere"
Workbooks.Open Filename:= _
"Y:\somehwere\Tables.xls"
Windows("calculation.xls").Activate
End Sub

This works as long as the macro is run in the file "calculation.xls".
How can I change it so that it will return to the file from which the
macro has been launched? I uderstand that I could change the name
"calculation.xls" each time for a new file, but I am sure that I and
others will sometimes forget and then have to go manually to that file.

Or is it possible to open the file "Y:\somehwere\Tables.xls" without it
going to the front?

houghi
--
This was written under the influence of the following:
| Artist : BBC Philharmonic
| Song : Symphony 6
| Album : The Beethoven Experience
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default Go back to the previous excel file

Just store the caption of the active workbook and use it to re-Activate the
window:

Sub dural()
Dim w As Window
Set w = ActiveWindow
n = w.Caption
'ChDir.......
'Workbooks.Open Filename:=.....
Windows(n).Activate
End Sub
--
Gary''s Student - gsnu200836


"houghi" wrote:

I have the following macro that works great:
Sub OpenData()
ChDir "Y:\somewhere"
Workbooks.Open Filename:= _
"Y:\somehwere\Tables.xls"
Windows("calculation.xls").Activate
End Sub

This works as long as the macro is run in the file "calculation.xls".
How can I change it so that it will return to the file from which the
macro has been launched? I uderstand that I could change the name
"calculation.xls" each time for a new file, but I am sure that I and
others will sometimes forget and then have to go manually to that file.

Or is it possible to open the file "Y:\somehwere\Tables.xls" without it
going to the front?

houghi
--
This was written under the influence of the following:
| Artist : BBC Philharmonic
| Song : Symphony 6
| Album : The Beethoven Experience

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 56
Default Go back to the previous excel file

Gary''s Student wrote:
Just store the caption of the active workbook and use it to re-Activate the
window:


Thanks, works great.

houghi
--
This was written under the influence of the following:
| Artist : Evanescence
| Song : Everybody's Fool
| Album : Not For Your Ears
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
can I get back previous version of a file I copied over in excel? jac34 Excel Discussion (Misc queries) 2 January 24th 06 01:35 AM
Match Last Occurrence of Numeric Value and Count BACK to Previous Sam via OfficeKB.com Excel Worksheet Functions 4 November 24th 05 02:15 AM
Revert back to previous file version vamorv2004 Excel Discussion (Misc queries) 2 May 17th 05 02:07 AM
Go back to previous worksheet BarryL New Users to Excel 2 May 5th 05 01:38 AM
Roll back to previous date Jay Excel Worksheet Functions 2 December 3rd 04 03:35 PM


All times are GMT +1. The time now is 09:28 AM.

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"