Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Code to switch between workbooks

Hi there,
I'll try to explain my situation as best as I can - I'm trying to write
some code to switch between workbooks - where the file names are
variables.

Standard code:
Windows("ABC.xls").Activate

How can I replace the "ABC.xls" so that I can switch to any workbook I
define, and not just ABC.xls?

Thanks for any help anyone might be able to provide
Thomas.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 156
Default Code to switch between workbooks

Binding that the workbooks are already open you can play around with
this code

Remember that you'll have to use the whole name(including the file
extension, example: Book2.xls

Sub TheSwitch()
Dim MyWkbk As String
MyWkbk = InputBox("Enter the workbook you'd like to activate")
Application.Windows(Result).Activate
End Sub




wrote:
Hi there,
I'll try to explain my situation as best as I can - I'm trying to write
some code to switch between workbooks - where the file names are
variables.

Standard code:
Windows("ABC.xls").Activate

How can I replace the "ABC.xls" so that I can switch to any workbook I
define, and not just ABC.xls?

Thanks for any help anyone might be able to provide
Thomas.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Code to switch between workbooks

Sandy,
Thanks for your input. I might be doing something wrong, but I just
copied the code into a blank module, and am getting a "Subscript out of
range" error. I do have the file open that I'm entering in the input
box, and entering the file extension too....

Any ideas?

Thanks for your time and advice!
Thomas.

Sandy wrote:
Binding that the workbooks are already open you can play around with
this code

Remember that you'll have to use the whole name(including the file
extension, example: Book2.xls

Sub TheSwitch()
Dim MyWkbk As String
MyWkbk = InputBox("Enter the workbook you'd like to activate")
Application.Windows(Result).Activate
End Sub




wrote:
Hi there,
I'll try to explain my situation as best as I can - I'm trying to write
some code to switch between workbooks - where the file names are
variables.

Standard code:
Windows("ABC.xls").Activate

How can I replace the "ABC.xls" so that I can switch to any workbook I
define, and not just ABC.xls?

Thanks for any help anyone might be able to provide
Thomas.


  #4   Report Post  
Posted to microsoft.public.excel.programming
Jay Jay is offline
external usenet poster
 
Posts: 671
Default Code to switch between workbooks

Try this
Sub TheSwitch()
Dim MyWkbk As String
MyWkbk = InputBox("Enter the workbook you'd like to activate")
Application.Windows(MyWkbk).Activate
End Sub

you were getting error because Result was not defined


" wrote:

Sandy,
Thanks for your input. I might be doing something wrong, but I just
copied the code into a blank module, and am getting a "Subscript out of
range" error. I do have the file open that I'm entering in the input
box, and entering the file extension too....

Any ideas?

Thanks for your time and advice!
Thomas.

Sandy wrote:
Binding that the workbooks are already open you can play around with
this code

Remember that you'll have to use the whole name(including the file
extension, example: Book2.xls

Sub TheSwitch()
Dim MyWkbk As String
MyWkbk = InputBox("Enter the workbook you'd like to activate")
Application.Windows(Result).Activate
End Sub




wrote:
Hi there,
I'll try to explain my situation as best as I can - I'm trying to write
some code to switch between workbooks - where the file names are
variables.

Standard code:
Windows("ABC.xls").Activate

How can I replace the "ABC.xls" so that I can switch to any workbook I
define, and not just ABC.xls?

Thanks for any help anyone might be able to provide
Thomas.



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
Using alt-tab to switch between Excel workbooks under the same session Kjetil Excel Discussion (Misc queries) 0 June 22nd 06 03:39 PM
How to switch between different workbooks? Ivan Excel Programming 2 December 28th 05 06:30 AM
URGENT: switch excel workbooks and display msgbox ilyaskazi[_15_] Excel Programming 2 June 4th 05 11:56 PM
Switch Workbooks Ronbo Excel Programming 1 February 29th 04 06:58 PM
Switch between workbooks Newbie Excel Programming 1 January 7th 04 09:34 PM


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