Hi - I have an issue with the VBA code below. This code runs seamlessly on my PC, however when trying to run it on another user's PC I get the following error message right when the code tries to execute the WinHttpReq.Send line (see below):
Run-time error '-2147012867 (80072efd)'
A connection with the server could not be established
User is able to view the content of the page when he enters URL, username and password manually. User tells me that I should be routing through his proxy. Please help! Thanks
********************************
Private Sub Command3_Click()
Dim oresp() As Byte
' Assemble an HTTP request.
Set WinHttpReq = New WinHttpRequest
' Assemble an HTTP request.
WinHttpReq.Open "GET", webaddress, False
' Set the user name and password.
WinHttpReq.SetCredentials username, password, HTTPREQUEST_SETCREDENTIALS_FOR_PROXY
' Send the HTTP Request.
WinHttpReq.Send ###### HERE IS WHERE ERROR HAPPENS #####
' Display the status code and response headers.
Text2.Text = WinHttpReq.Status & " " & WinHttpReq.StatusText
Text1.Text = WinHttpReq.GetAllResponseHeaders & " " & WinHttpReq.ResponseText
oresp = WinHttpReq.ResponseBody 'Returns the results as a byte array
vLocalFile = "C:/test.csv"
'Create local file and save results to it
vFF = FreeFile
If Dir(vLocalFile) <> "" Then Kill vLocalFile
Open vLocalFile For Binary As #vFF
Put #vFF, , oresp
Close #vFF
End Sub
Run-time error '-2147012867 (80072efd)'
A connection with the server could not be established
User is able to view the content of the page when he enters URL, username and password manually. User tells me that I should be routing through his proxy. Please help! Thanks
********************************
Private Sub Command3_Click()
Dim oresp() As Byte
' Assemble an HTTP request.
Set WinHttpReq = New WinHttpRequest
' Assemble an HTTP request.
WinHttpReq.Open "GET", webaddress, False
' Set the user name and password.
WinHttpReq.SetCredentials username, password, HTTPREQUEST_SETCREDENTIALS_FOR_PROXY
' Send the HTTP Request.
WinHttpReq.Send ###### HERE IS WHERE ERROR HAPPENS #####
' Display the status code and response headers.
Text2.Text = WinHttpReq.Status & " " & WinHttpReq.StatusText
Text1.Text = WinHttpReq.GetAllResponseHeaders & " " & WinHttpReq.ResponseText
oresp = WinHttpReq.ResponseBody 'Returns the results as a byte array
vLocalFile = "C:/test.csv"
'Create local file and save results to it
vFF = FreeFile
If Dir(vLocalFile) <> "" Then Kill vLocalFile
Open vLocalFile For Binary As #vFF
Put #vFF, , oresp
Close #vFF
End Sub