PC Review


Reply
Thread Tools Rate Thread

Activating an open file with a variable name

 
 
Andyjim
Guest
Posts: n/a
 
      21st Dec 2007

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 With Quote
 
 
 
 
Otto Moehrbach
Guest
Posts: n/a
 
      21st Dec 2007
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" <(E-Mail Removed)> wrote in message
news:C065A815-60D1-4458-97FB-(E-Mail Removed)...
>
> 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 With Quote
 
Andyjim
Guest
Posts: n/a
 
      21st Dec 2007
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" <(E-Mail Removed)> wrote in message
> news:C065A815-60D1-4458-97FB-(E-Mail Removed)...
> >
> > 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 With Quote
 
Otto Moehrbach
Guest
Posts: n/a
 
      21st Dec 2007
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" <(E-Mail Removed)> wrote in message
news:E0C18BE8-05BB-47AC-B99D-(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
>> news:C065A815-60D1-4458-97FB-(E-Mail Removed)...
>> >
>> > 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 With Quote
 
Andyjim
Guest
Posts: n/a
 
      21st Dec 2007
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" <(E-Mail Removed)> wrote in message
> news:E0C18BE8-05BB-47AC-B99D-(E-Mail Removed)...
> > 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" <(E-Mail Removed)> wrote in message
> >> news:C065A815-60D1-4458-97FB-(E-Mail Removed)...
> >> >
> >> > 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 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
Define variable from cell to open a file =?Utf-8?B?QW1pcg==?= Microsoft Excel Programming 2 17th Aug 2007 01:55 AM
RE: Define variable from cell to open a file =?Utf-8?B?SmltIFRob21saW5zb24=?= Microsoft Excel Programming 0 17th Aug 2007 01:45 AM
Activating a worksheet through use of a variable =?Utf-8?B?Q2Fkcw==?= Microsoft Excel Worksheet Functions 2 7th Feb 2006 10:45 AM
open file (as variable) from macro =?Utf-8?B?ZCBjaGFwcw==?= Microsoft Excel Misc 1 14th Mar 2005 11:57 PM
Activating workbook with variable Name Mark Klaus Microsoft Excel Programming 2 24th Oct 2003 10:41 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:44 PM.