PC Review


Reply
Thread Tools Rate Thread

Code to switch between workbooks

 
 
thomascrajan@gmail.com
Guest
Posts: n/a
 
      10th Oct 2006
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 With Quote
 
 
 
 
Sandy
Guest
Posts: n/a
 
      10th Oct 2006
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




(E-Mail Removed) 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 With Quote
 
thomascrajan@gmail.com
Guest
Posts: n/a
 
      10th Oct 2006
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
>
>
>
>
> (E-Mail Removed) 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 With Quote
 
=?Utf-8?B?SmF5?=
Guest
Posts: n/a
 
      11th Oct 2006
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


"(E-Mail Removed)" 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
> >
> >
> >
> >
> > (E-Mail Removed) 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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Switch Between Workbooks =?Utf-8?B?SmFzb24=?= Microsoft Excel Programming 4 13th Jun 2007 09:30 AM
Using alt-tab to switch between Excel workbooks under the same session Kjetil Microsoft Excel Discussion 0 22nd Jun 2006 03:39 PM
How to switch between different workbooks? =?Utf-8?B?SXZhbg==?= Microsoft Excel Programming 2 28th Dec 2005 06:30 AM
Switch Workbooks Ronbo Microsoft Excel Programming 1 29th Feb 2004 06:58 PM
Switch between workbooks =?Utf-8?B?TmV3Ymll?= Microsoft Excel Programming 1 7th Jan 2004 09:34 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:26 AM.