ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Workbooks.Open(URL) not working (https://www.excelbanter.com/excel-programming/374112-workbooks-open-url-not-working.html)

[email protected]

Workbooks.Open(URL) not working
 
Hi,

Can anyone suggest a workaround for the following in XL97 SR2 please?
I'm trying to open a workbook from a web download, however, the
workbook will not open if it is invoked from VBA (it is called from a
Workbook_Open event). But it will work if I simply run the code. I
can't find an explanation for this odd behaviour so I'm wondering if
there is a workaround to download a sheet from this excel workbook held
on a web site.

Sub GetDataSheet
strURL = "http://server//SpreadsheetToOpen.xls"
Set myWB = Workbooks.Open (strURL)
End Sub

(btw, there is no other code in the Workbook_Open event and the URL is
very simple with no strange characters).

Many thanks in advance if anyone can help.

Regards,
Chris Adams


Dave Peterson

Workbooks.Open(URL) not working
 
Try moving the code from workbook_Open() to Auto_Open() (in a general module).

(Untested)

wrote:

Hi,

Can anyone suggest a workaround for the following in XL97 SR2 please?
I'm trying to open a workbook from a web download, however, the
workbook will not open if it is invoked from VBA (it is called from a
Workbook_Open event). But it will work if I simply run the code. I
can't find an explanation for this odd behaviour so I'm wondering if
there is a workaround to download a sheet from this excel workbook held
on a web site.

Sub GetDataSheet
strURL = "http://server//SpreadsheetToOpen.xls"
Set myWB = Workbooks.Open (strURL)
End Sub

(btw, there is no other code in the Workbook_Open event and the URL is
very simple with no strange characters).

Many thanks in advance if anyone can help.

Regards,
Chris Adams


--

Dave Peterson

[email protected]

Workbooks.Open(URL) not working
 
Dave,

Many, many thanks - that worked a treat..!! I'm awestruck because its
hard to tell how many years of experience went behind that simple,
left-field solution :-)

I've tested your solution on a couple of PCs so far - all worked fine.


Heck of a relief because I'd made a commitment that this opening the
URL workbook was easy stuff anyone could do, but then it blew up over
this illogical problem and I've been sweating all weekend trying to
figure a solution. You've saved my derriere!

Much appreciated again,
Chris Adams

Dave Peterson wrote:

Try moving the code from workbook_Open() to Auto_Open() (in a general module).



Dave Peterson

Workbooks.Open(URL) not working
 
It's been awhile, but I have seen posts like this:

I have seen posts like this that:

Private Sub Workbook_Open()
Application.OnTime Now, "Continue_Open"
End Sub

Then in a general module:

sub Continue_Open()
'your real code here
end sub

Sometimes there would be timing issues that could be avoided this way. (I've
never seen this in real life, though--but others have.)

wrote:

Dave,

Many, many thanks - that worked a treat..!! I'm awestruck because its
hard to tell how many years of experience went behind that simple,
left-field solution :-)

I've tested your solution on a couple of PCs so far - all worked fine.

Heck of a relief because I'd made a commitment that this opening the
URL workbook was easy stuff anyone could do, but then it blew up over
this illogical problem and I've been sweating all weekend trying to
figure a solution. You've saved my derriere!

Much appreciated again,
Chris Adams

Dave Peterson wrote:

Try moving the code from workbook_Open() to Auto_Open() (in a general module).


--

Dave Peterson


All times are GMT +1. The time now is 04:18 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com