Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default Calling open workbook from another workbook

I'm switching back and forth between two workbooks. I open Book1 from the
ThisWorkbook_Open event in Book2, then switch back to Book2 with a
Me.Activate since I'm still in it. How do I switch back to the already opened
Book1? Presumably this is also how I would switch back to Book2 while in
Book1?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Calling open workbook from another workbook

Windows("Book2").Activate
or
Windows("Book2.xls").Activate

depending on what is in the Window Title Bar.
--
Gary''s Student - gsnu200908


"Merlynsdad" wrote:

I'm switching back and forth between two workbooks. I open Book1 from the
ThisWorkbook_Open event in Book2, then switch back to Book2 with a
Me.Activate since I'm still in it. How do I switch back to the already opened
Book1? Presumably this is also how I would switch back to Book2 while in
Book1?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default Calling open workbook from another workbook

That would do it if it were local, but it's out on a network and I'm
referring to it with Constant "cstrDatabaseWB". Using the constant either
with the "" or without doesn't work. I forgot to mention I'm also running the
code in the click event of a listbox.

"Gary''s Student" wrote:

Windows("Book2").Activate
or
Windows("Book2.xls").Activate

depending on what is in the Window Title Bar.
--
Gary''s Student - gsnu200908


"Merlynsdad" wrote:

I'm switching back and forth between two workbooks. I open Book1 from the
ThisWorkbook_Open event in Book2, then switch back to Book2 with a
Me.Activate since I'm still in it. How do I switch back to the already opened
Book1? Presumably this is also how I would switch back to Book2 while in
Book1?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default Calling open workbook from another workbook

gary's answer is correct if you have two or more workbooks open ... all you
need to do is activate the one that to want to use. Are you now saying that
when you "switch" to book 2 that you actually CLOSE book1? I' m not clear on
thios question.


"Merlynsdad" wrote:

That would do it if it were local, but it's out on a network and I'm
referring to it with Constant "cstrDatabaseWB". Using the constant either
with the "" or without doesn't work. I forgot to mention I'm also running the
code in the click event of a listbox.

"Gary''s Student" wrote:

Windows("Book2").Activate
or
Windows("Book2.xls").Activate

depending on what is in the Window Title Bar.
--
Gary''s Student - gsnu200908


"Merlynsdad" wrote:

I'm switching back and forth between two workbooks. I open Book1 from the
ThisWorkbook_Open event in Book2, then switch back to Book2 with a
Me.Activate since I'm still in it. How do I switch back to the already opened
Book1? Presumably this is also how I would switch back to Book2 while in
Book1?

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default Calling open workbook from another workbook

No, I'm not closing Book1, I'm just activating it and switching back and
forth from Book1 to Book 2 as I copy and paste. If I use the actual name of
the workbook "real1.xls" it works fine. However when I input the constant
cstrDatabaseWB in the command:

Windows(cstrDatabaseWB).Activate

I get a runtime Error 9, "subscript out of range" error.

The constant is currently defined as:

Const cstrDatabaseWB As String = "C:\Documents and Settings\5YPJB\My
Documents\Excel documents\Sherry project\real1.xls"

because I'm writing this on my machine, but the constant will eventually end
up with a network path.


"Patrick Molloy" wrote:

gary's answer is correct if you have two or more workbooks open ... all you
need to do is activate the one that to want to use. Are you now saying that
when you "switch" to book 2 that you actually CLOSE book1? I' m not clear on
thios question.


"Merlynsdad" wrote:

That would do it if it were local, but it's out on a network and I'm
referring to it with Constant "cstrDatabaseWB". Using the constant either
with the "" or without doesn't work. I forgot to mention I'm also running the
code in the click event of a listbox.

"Gary''s Student" wrote:

Windows("Book2").Activate
or
Windows("Book2.xls").Activate

depending on what is in the Window Title Bar.
--
Gary''s Student - gsnu200908


"Merlynsdad" wrote:

I'm switching back and forth between two workbooks. I open Book1 from the
ThisWorkbook_Open event in Book2, then switch back to Book2 with a
Me.Activate since I'm still in it. How do I switch back to the already opened
Book1? Presumably this is also how I would switch back to Book2 while in
Book1?



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default Calling open workbook from another workbook

thats becasue the workbook name in the activate method is just the name and
excludes the path

try
Const cstrDatabaseWB As String = "real1.xls"


"Merlynsdad" wrote:

No, I'm not closing Book1, I'm just activating it and switching back and
forth from Book1 to Book 2 as I copy and paste. If I use the actual name of
the workbook "real1.xls" it works fine. However when I input the constant
cstrDatabaseWB in the command:

Windows(cstrDatabaseWB).Activate

I get a runtime Error 9, "subscript out of range" error.

The constant is currently defined as:

Const cstrDatabaseWB As String = "C:\Documents and Settings\5YPJB\My
Documents\Excel documents\Sherry project\real1.xls"

because I'm writing this on my machine, but the constant will eventually end
up with a network path.


"Patrick Molloy" wrote:

gary's answer is correct if you have two or more workbooks open ... all you
need to do is activate the one that to want to use. Are you now saying that
when you "switch" to book 2 that you actually CLOSE book1? I' m not clear on
thios question.


"Merlynsdad" wrote:

That would do it if it were local, but it's out on a network and I'm
referring to it with Constant "cstrDatabaseWB". Using the constant either
with the "" or without doesn't work. I forgot to mention I'm also running the
code in the click event of a listbox.

"Gary''s Student" wrote:

Windows("Book2").Activate
or
Windows("Book2.xls").Activate

depending on what is in the Window Title Bar.
--
Gary''s Student - gsnu200908


"Merlynsdad" wrote:

I'm switching back and forth between two workbooks. I open Book1 from the
ThisWorkbook_Open event in Book2, then switch back to Book2 with a
Me.Activate since I'm still in it. How do I switch back to the already opened
Book1? Presumably this is also how I would switch back to Book2 while in
Book1?

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
Open a specific workbook...find value from other open workbook and then insert cells values in cell next to it. [email protected] Excel Programming 1 May 13th 07 01:46 PM
Passing calling workbook name to called workbook DRK Excel Programming 7 May 6th 06 01:34 AM
Reference code in another workbook from a calling workbook Datasort Excel Programming 1 January 4th 05 01:13 AM
Open a password protected excel workbook from second workbook to fetch data using dynamic connection kaustav choudhury Excel Programming 2 April 3rd 04 06:18 AM
What commands do you use to name a workbook, save a workbook,open a workbook Steven R. Berke Excel Programming 1 July 24th 03 11:37 PM


All times are GMT +1. The time now is 08:53 AM.

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"