Greetings, Board.
I use this:
And it downloads the files I specify quite nicely.
However, when I attempt to open the downloaded files with a "Workbooks.Open" commend, I get a Runtime 1004 error sayng the file format or extension is not valid. I am naming the exact file and extension in the dowload code, as you can see. It also advises to insure the file has not been corrupted and that the extension matches the format. Unknown how to do that . . .
When I manually download the file it opens just fine so, I am corn-fused.
The file does contain macros and Pivot Tables, but the process doesn't demand links, as the macros obtain the data necessary through simple copy-n-paste commands.
What's the incredibly obvious part I can't see?
Thanks.
I use this:
Rich (BB code):
Sub Downlodez()
Dim FileNum As Long
Dim FileData() As Byte
Dim MyFile As String
Dim WHTTP As Object
On Error Resume Next
Set WHTTP = CreateObject("WinHTTP.WinHTTPrequest.5")
If Err.Number <> 0 Then
Set WHTTP = CreateObject("WinHTTP.WinHTTPrequest.5.1")
End If
On Error GoTo 0
MyFile = "http://thatsite.com/sites/NoBigFile.xlsm"
WHTTP.Open "GET", MyFile, False
WHTTP.Send
FileData = WHTTP.ResponseBody
Set WHTTP = Nothing
If Dir("G:\Huge\Medium\Small", vbDirectory) = Empty Then _
MkDir "G:\Huge\Medium\Small"
FileNum = FreeFile
Open "G:\Huge\Medium\Small\NoBigFile.xlsm" For Binary Access Write As #FileNum
Put #FileNum, 1, FileData
Close #FileNum
End Sub
And it downloads the files I specify quite nicely.
However, when I attempt to open the downloaded files with a "Workbooks.Open" commend, I get a Runtime 1004 error sayng the file format or extension is not valid. I am naming the exact file and extension in the dowload code, as you can see. It also advises to insure the file has not been corrupted and that the extension matches the format. Unknown how to do that . . .
When I manually download the file it opens just fine so, I am corn-fused.
The file does contain macros and Pivot Tables, but the process doesn't demand links, as the macros obtain the data necessary through simple copy-n-paste commands.
What's the incredibly obvious part I can't see?
Thanks.
Last edited: