Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default Activating an open file with a variable name


I have 2 files open that I need to go back and forth with.

File 1 is defined with a variable name oWB.

File 2 is called Update.xls

When I am in Update.xls and want to go back to oWB, how to I do that?

oWB.Activate doesn't seem to work. Any suggestions would be greatly
appreciated.

Andy
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,090
Default Activating an open file with a variable name

What do you want to do when you "go back to oWB? oWB.Activate makes the oWB
file the active file. That doesn't mean that it will be on your screen.
That depends on your code.. What do you want to happen? HTH Otto
"Andyjim" wrote in message
...

I have 2 files open that I need to go back and forth with.

File 1 is defined with a variable name oWB.

File 2 is called Update.xls

When I am in Update.xls and want to go back to oWB, how to I do that?

oWB.Activate doesn't seem to work. Any suggestions would be greatly
appreciated.

Andy



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default Activating an open file with a variable name

Hi Otto-
Thanks for your quick reply. The macro will do things like copy one of the
worksheets to the Update file and similar tasks. It doesn't need to appear
on the screen, but needs to get the job done.

The reason for file 1 having a variable name is because we don't necessarily
know the name of the user's file. Perhaps the explanation below will explain
what we trying to do more clearly. At this point, I just need to get back
to FIle 1 (with the variable name). In case there would be a different
approach, the 1st part of the macro puts the actual name of that file in a
cell in file 2 (the Update file). Perhaps we could reference it and activate
it using that name, but I didn't succeed doing that either.

In an earlier post I referenced this situation:

We have put together a small trading
system which we plan to send out to users. In order to accommodate future
updates, we want to be able to take the name of the user's file (which we
don't know for sure) and identify that name so that we eventually save the
update as that name. Also, in the process, we will need to be copying
history data from the original file to the update file so we need to be able
to go back and forth between files.




"Otto Moehrbach" wrote:

What do you want to do when you "go back to oWB? oWB.Activate makes the oWB
file the active file. That doesn't mean that it will be on your screen.
That depends on your code.. What do you want to happen? HTH Otto
"Andyjim" wrote in message
...

I have 2 files open that I need to go back and forth with.

File 1 is defined with a variable name oWB.

File 2 is called Update.xls

When I am in Update.xls and want to go back to oWB, how to I do that?

oWB.Activate doesn't seem to work. Any suggestions would be greatly
appreciated.

Andy




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,090
Default Activating an open file with a variable name

I'm not sure I understand what you are doing or want to do. You said
earlier that you had set the variable oWB to that "user's file". Exactly
how did you do that? Post that line of code that sets that variable.
You also say that the name of that file is in some cell in the Update file.
If the Update file is the active file, and the cell that holds the user's
file name is A1 in sheet "TheSht", and if the user's file is open, you can
use something like this:
Set oWB=Workbooks(Sheets("TheSht").Range("A1").Value).
If the user's file is not open, then you have to have the path to that file,
say "ThePath", and use something like:
Set oWB = Workbooks.Open(ThePath & Sheets("TheSht").Range("A1").Value)

Note that the string ThePath has to have a backslash at the end for this to
work.
Note that the oWB file will be the active file once it is opened with the
above "Open" statement. Otto
"Andyjim" wrote in message
...
Hi Otto-
Thanks for your quick reply. The macro will do things like copy one of
the
worksheets to the Update file and similar tasks. It doesn't need to
appear
on the screen, but needs to get the job done.

The reason for file 1 having a variable name is because we don't
necessarily
know the name of the user's file. Perhaps the explanation below will
explain
what we trying to do more clearly. At this point, I just need to get
back
to FIle 1 (with the variable name). In case there would be a different
approach, the 1st part of the macro puts the actual name of that file in
a
cell in file 2 (the Update file). Perhaps we could reference it and
activate
it using that name, but I didn't succeed doing that either.

In an earlier post I referenced this situation:

We have put together a small trading
system which we plan to send out to users. In order to accommodate future
updates, we want to be able to take the name of the user's file (which we
don't know for sure) and identify that name so that we eventually save the
update as that name. Also, in the process, we will need to be copying
history data from the original file to the update file so we need to be
able
to go back and forth between files.




"Otto Moehrbach" wrote:

What do you want to do when you "go back to oWB? oWB.Activate makes the
oWB
file the active file. That doesn't mean that it will be on your screen.
That depends on your code.. What do you want to happen? HTH Otto
"Andyjim" wrote in message
...

I have 2 files open that I need to go back and forth with.

File 1 is defined with a variable name oWB.

File 2 is called Update.xls

When I am in Update.xls and want to go back to oWB, how to I do that?

oWB.Activate doesn't seem to work. Any suggestions would be greatly
appreciated.

Andy






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default Activating an open file with a variable name

Hi Otto-

Your suggestion "Set oWB=Workbooks(Sheets("TheSht").Range("A1").Value)"
worked beautifully. Thank you so much!

"Otto Moehrbach" wrote:

I'm not sure I understand what you are doing or want to do. You said
earlier that you had set the variable oWB to that "user's file". Exactly
how did you do that? Post that line of code that sets that variable.
You also say that the name of that file is in some cell in the Update file.
If the Update file is the active file, and the cell that holds the user's
file name is A1 in sheet "TheSht", and if the user's file is open, you can
use something like this:
Set oWB=Workbooks(Sheets("TheSht").Range("A1").Value).
If the user's file is not open, then you have to have the path to that file,
say "ThePath", and use something like:
Set oWB = Workbooks.Open(ThePath & Sheets("TheSht").Range("A1").Value)

Note that the string ThePath has to have a backslash at the end for this to
work.
Note that the oWB file will be the active file once it is opened with the
above "Open" statement. Otto
"Andyjim" wrote in message
...
Hi Otto-
Thanks for your quick reply. The macro will do things like copy one of
the
worksheets to the Update file and similar tasks. It doesn't need to
appear
on the screen, but needs to get the job done.

The reason for file 1 having a variable name is because we don't
necessarily
know the name of the user's file. Perhaps the explanation below will
explain
what we trying to do more clearly. At this point, I just need to get
back
to FIle 1 (with the variable name). In case there would be a different
approach, the 1st part of the macro puts the actual name of that file in
a
cell in file 2 (the Update file). Perhaps we could reference it and
activate
it using that name, but I didn't succeed doing that either.

In an earlier post I referenced this situation:

We have put together a small trading
system which we plan to send out to users. In order to accommodate future
updates, we want to be able to take the name of the user's file (which we
don't know for sure) and identify that name so that we eventually save the
update as that name. Also, in the process, we will need to be copying
history data from the original file to the update file so we need to be
able
to go back and forth between files.




"Otto Moehrbach" wrote:

What do you want to do when you "go back to oWB? oWB.Activate makes the
oWB
file the active file. That doesn't mean that it will be on your screen.
That depends on your code.. What do you want to happen? HTH Otto
"Andyjim" wrote in message
...

I have 2 files open that I need to go back and forth with.

File 1 is defined with a variable name oWB.

File 2 is called Update.xls

When I am in Update.xls and want to go back to oWB, how to I do that?

oWB.Activate doesn't seem to work. Any suggestions would be greatly
appreciated.

Andy








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
Define variable from cell to open a file Amir Excel Programming 2 August 17th 07 01:51 AM
Define variable from cell to open a file Jim Thomlinson Excel Programming 0 August 17th 07 01:45 AM
Activating a worksheet through use of a variable Cads Excel Worksheet Functions 2 February 7th 06 10:45 AM
open file (as variable) from macro d chaps Excel Discussion (Misc queries) 1 March 14th 05 11:57 PM
Activating workbook with variable Name Mark Klaus Excel Programming 2 October 24th 03 10:41 PM


All times are GMT +1. The time now is 01:20 PM.

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"