WinHTTP - Run-time error '-2147012867 (80072efd)'

muffin123

New Member
Joined
May 3, 2011
Messages
2
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
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Have you checked firewall settings, connectivity (in case of timeouts), file path/names...?

Those are some of the things that can cause this problem.

I don't know much more than that - I hardly ever use WinHTTP and can't recall having that specific error.

I'm sure I had some error (might actually have been that one) but I think it was solved by changing some setting on the machine.
 
Upvote 0
Thanks Norie.

Another question regarding this - for some reason user has to close and reopen sheet several times before he can establish a connection and successfully complete the request.

I included a loop to have the code make 10 attempts and avoid having to open/close the sheet but it was still unsuccessful.

Any idea on how to solve this?
 
Upvote 0
Apologies for returning to an old post, but I have the same error message described in the original post, doing basically the same task. I would like to open a hyperlink (to a csv file) embeded in an email (from Barclays' POINT) through vba. Manually it works ok when I click on the link.
Has anybody else had this error? How did you solve it?

Thanks in advance for the help.
 
Upvote 0

Forum statistics

Threads
1,224,590
Messages
6,179,756
Members
452,940
Latest member
rootytrip

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top