I’m attempting to use VBA to download a file via a http request. If I put the myURL value into a browser I get an authentication page, and after login, taken to the file with an “open” prompt. However, when I use this code, all I get is a file with the Domino Login page in it.
Has anyone done this or something similar? Any ideas or other ways of doing this? Help? Thoughts?
Thank you for looking, and thank you for your help and advise.
VBA CODE:
Sub DownloadFile()
Dim myURL As String
myURL = “http://192.168.0.2/P&P/pp681Dev.nsf/0/84e8316d0287db8787257ead0058ae62/$FILE/PNPTempWord.doc http://192.168.0.2/P&P/pp681Dev.nsf/0/84e8316d0287db8787257ead0058ae62/$FILE/PNPTempWord.doc&User=Tim”
Dim WinHttpReq As Object
Set WinHttpReq = CreateObject(“Microsoft.XMLHTTP”)
WinHttpReq.open “GET”, myURL, False, “username”, “password”
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\PNPTempWord.doc”, 2 ’ 1 = no overwrite, 2 = overwrite
oStream.Close
End If
End Sub