PC Review


Reply
Thread Tools Rate Thread

How do assign a name to a remote workbook ?

 
 
Dan Thompson
Guest
Posts: n/a
 
      11th Apr 2008
I am trying to have my VBA code open a workbook from a website however I
don't want to have to keep refering to the whole URL name every time I need
to call it or work with it in my code so I just want to assign a short name
variable to represent it and currently my code is giving me a subscript out
of range error here is my code

Dim WPSR As Workbook
This is the code that is not working
Set WPSR =
Workbooks("http://tonto.eia.doe.gov/oog/ftparea/wogirs/xls/psw03.xls")
Workbooks.Open WPSR


This is my original code to open the file
'Workbooks.Open
Filename:="http://tonto.eia.doe.gov/oog/ftparea/wogirs/xls/psw03.xls"
'Sheets("Data 1").Select
'ActiveWindow.SmallScroll Down:=3


 
Reply With Quote
 
 
 
 
Gary''s Student
Guest
Posts: n/a
 
      11th Apr 2008
Once you have opened the file (using the code that works) the name should be
available:

Dim remoteWB as string
remoteWB=ActiveWorkbook.Name
--
Gary''s Student - gsnu200778


"Dan Thompson" wrote:

> I am trying to have my VBA code open a workbook from a website however I
> don't want to have to keep refering to the whole URL name every time I need
> to call it or work with it in my code so I just want to assign a short name
> variable to represent it and currently my code is giving me a subscript out
> of range error here is my code
>
> Dim WPSR As Workbook
> This is the code that is not working
> Set WPSR =
> Workbooks("http://tonto.eia.doe.gov/oog/ftparea/wogirs/xls/psw03.xls")
> Workbooks.Open WPSR
>
>
> This is my original code to open the file
> 'Workbooks.Open
> Filename:="http://tonto.eia.doe.gov/oog/ftparea/wogirs/xls/psw03.xls"
> 'Sheets("Data 1").Select
> 'ActiveWindow.SmallScroll Down:=3
>
>

 
Reply With Quote
 
Dan Thompson
Guest
Posts: n/a
 
      11th Apr 2008
Ok That will probably work however I am looking for a way to do this without
using the ActiveWorkbook Function. For my purpose I would prefer code to
reference the remote workbook directly by its name because if I use your code
then whenever I have another workbook that is the active workbook the code
will be referencing the wrong workbook wont it ? Or dose VBA remember the
workbook name RemoteWB as the Active workbook that it first referenced at the
time you assigned RemotWB to it ?


"Gary''s Student" wrote:

> Once you have opened the file (using the code that works) the name should be
> available:
>
> Dim remoteWB as string
> remoteWB=ActiveWorkbook.Name
> --
> Gary''s Student - gsnu200778
>
>
> "Dan Thompson" wrote:
>
> > I am trying to have my VBA code open a workbook from a website however I
> > don't want to have to keep refering to the whole URL name every time I need
> > to call it or work with it in my code so I just want to assign a short name
> > variable to represent it and currently my code is giving me a subscript out
> > of range error here is my code
> >
> > Dim WPSR As Workbook
> > This is the code that is not working
> > Set WPSR =
> > Workbooks("http://tonto.eia.doe.gov/oog/ftparea/wogirs/xls/psw03.xls")
> > Workbooks.Open WPSR
> >
> >
> > This is my original code to open the file
> > 'Workbooks.Open
> > Filename:="http://tonto.eia.doe.gov/oog/ftparea/wogirs/xls/psw03.xls"
> > 'Sheets("Data 1").Select
> > 'ActiveWindow.SmallScroll Down:=3
> >
> >

 
Reply With Quote
 
Gary''s Student
Guest
Posts: n/a
 
      11th Apr 2008
O.K.......the trick is that when you Open a workbook, it becomes the
ActiveWorkbook.


Might as well remember its name while you are there.
--
Gary''s Student - gsnu200778


"Dan Thompson" wrote:

> Ok That will probably work however I am looking for a way to do this without
> using the ActiveWorkbook Function. For my purpose I would prefer code to
> reference the remote workbook directly by its name because if I use your code
> then whenever I have another workbook that is the active workbook the code
> will be referencing the wrong workbook wont it ? Or dose VBA remember the
> workbook name RemoteWB as the Active workbook that it first referenced at the
> time you assigned RemotWB to it ?
>
>
> "Gary''s Student" wrote:
>
> > Once you have opened the file (using the code that works) the name should be
> > available:
> >
> > Dim remoteWB as string
> > remoteWB=ActiveWorkbook.Name
> > --
> > Gary''s Student - gsnu200778
> >
> >
> > "Dan Thompson" wrote:
> >
> > > I am trying to have my VBA code open a workbook from a website however I
> > > don't want to have to keep refering to the whole URL name every time I need
> > > to call it or work with it in my code so I just want to assign a short name
> > > variable to represent it and currently my code is giving me a subscript out
> > > of range error here is my code
> > >
> > > Dim WPSR As Workbook
> > > This is the code that is not working
> > > Set WPSR =
> > > Workbooks("http://tonto.eia.doe.gov/oog/ftparea/wogirs/xls/psw03.xls")
> > > Workbooks.Open WPSR
> > >
> > >
> > > This is my original code to open the file
> > > 'Workbooks.Open
> > > Filename:="http://tonto.eia.doe.gov/oog/ftparea/wogirs/xls/psw03.xls"
> > > 'Sheets("Data 1").Select
> > > 'ActiveWindow.SmallScroll Down:=3
> > >
> > >

 
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
assign macro to active workbook?? =?Utf-8?B?S2V2aW4=?= Microsoft Excel Programming 1 18th Oct 2007 06:05 PM
Export report into Excel workbook and ---> assign a PW to that workbook A C Microsoft Access Reports 1 24th Nov 2005 03:47 PM
Assign a Custom Toolbar to only one WorkBook Ken Soenen Microsoft Excel Discussion 3 28th Sep 2005 01:59 PM
assign workbook name and workbook builtinProperties Steven Microsoft Excel Misc 0 11th May 2005 12:56 AM
Macro to assign a printer to a workbook Gordon Forbes Microsoft Excel Programming 6 25th Feb 2004 10:00 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:43 AM.