Hi,
I'd appreciate any help on this.
I have a URL that when clicked it automatically downloads an Excel file to the Downloads folder on the C drive (C:\Users\Gill\Downloads)
I am then going to use the data in that downloaded Excel file to populate a report - that's the easy bit!
I'm having trouble (a) downloading the file from the URL and putting it in the C:\Temp\ folder and then (b) just opening the file using a Macro.
This is the code I am using at the moment:
Dim myURL As String
myURL = "http://regonline.blahblah.com/activereports/smartLink.aspx?eventid=Xhp4iBccSYE=&crid=161285"
Dim WinHttpReq As Object
Set WinHttpReq = CreateObject("Microsoft.XMLHTTP")
WinHttpReq.Open "GET", myURL, False
WinHttpReq.Send
myURL = WinHttpReq.ResponseBody
If WinHttpReq.Status = 200 Then
Set oStream = CreateObject("ADODB.Stream")
oStream.Open
oStream.Type = 1
oStream.Write WinHttpReq.ResponseBody
oStream.SaveToFile ("C:\Temp\")
oStream.Close
End If
The debugger stops the code at WinHttpReq.Send.
After that I need to open the file automatically and then import the data into another file. I'm stuck just on opening the file, not the importing of the data...
In and ideal world I would have a macro that when the user clicks the button in the report workbook it would automatically to the following steps:
1. download the file from the static URL
2. import the data from the downloaded file directly in a specified worksheet in the report workbook.
I'm sorry I have nothing more to give on this, but any help at all would be very welcome.
Thanks
GillB
I'd appreciate any help on this.
I have a URL that when clicked it automatically downloads an Excel file to the Downloads folder on the C drive (C:\Users\Gill\Downloads)
I am then going to use the data in that downloaded Excel file to populate a report - that's the easy bit!
I'm having trouble (a) downloading the file from the URL and putting it in the C:\Temp\ folder and then (b) just opening the file using a Macro.
This is the code I am using at the moment:
Dim myURL As String
myURL = "http://regonline.blahblah.com/activereports/smartLink.aspx?eventid=Xhp4iBccSYE=&crid=161285"
Dim WinHttpReq As Object
Set WinHttpReq = CreateObject("Microsoft.XMLHTTP")
WinHttpReq.Open "GET", myURL, False
WinHttpReq.Send
myURL = WinHttpReq.ResponseBody
If WinHttpReq.Status = 200 Then
Set oStream = CreateObject("ADODB.Stream")
oStream.Open
oStream.Type = 1
oStream.Write WinHttpReq.ResponseBody
oStream.SaveToFile ("C:\Temp\")
oStream.Close
End If
The debugger stops the code at WinHttpReq.Send.
After that I need to open the file automatically and then import the data into another file. I'm stuck just on opening the file, not the importing of the data...
In and ideal world I would have a macro that when the user clicks the button in the report workbook it would automatically to the following steps:
1. download the file from the static URL
2. import the data from the downloaded file directly in a specified worksheet in the report workbook.
I'm sorry I have nothing more to give on this, but any help at all would be very welcome.
Thanks
GillB