Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 125
Default How do assign a name to a remote workbook ?

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default How do assign a name to a remote workbook ?

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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 125
Default How do assign a name to a remote workbook ?

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


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default How do assign a name to a remote workbook ?

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
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
Sharing an Excel Workbook and Remote Web Access DougS Excel Discussion (Misc queries) 0 August 28th 07 03:26 PM
assign workbook name and workbook builtinProperties Steven Excel Discussion (Misc queries) 0 May 11th 05 12:56 AM
Is it possible to share Excel workbook with a remote user?? Kunal[_2_] Excel Programming 1 March 23rd 05 10:53 PM
Macro to assign a printer to a workbook Gordon Forbes Excel Programming 6 February 25th 04 10:00 AM
Database Filtering and Import or Copy to Remote Client Workbook battle Excel Programming 0 December 2nd 03 01:02 AM


All times are GMT +1. The time now is 04:40 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"