MSXML2.XMLHTTP, sendrequest in run time error '-2146697211 (800c0005)': The system cannot locate the resource specified

Nelson78

Well-known Member
Joined
Sep 11, 2017
Messages
526
Office Version
  1. 2007
Hello everybody.

I've a .xlsm folder last saved on 25th October 2019.

Until then, no problem.

Now, I've tried to run a macro without having modified it, but the result is:

run time error '-2146697211 (800c0005)': The system cannot locate the resource specified

in the line

Code:
.send


What could it be happened? Perhaps a change in firewall policy by the administrator?

VBA Code:
Sub getintothewebsite()

    Dim URL As String, strResponse As String
    Dim objHTTP As Object
    Dim city As String
   
    city = Range("B1")
   
    Set HTMLdoc = CreateObject("htmlfile")
   
    URL = "https://it.wikipedia.org/wiki/" & city
   
    Set objHTTP = CreateObject("MSXML2.XMLHTTP")

    With objHTTP
        .Open "GET", URL, False
        .setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
        .send
        strResponse = .responseText
        'MsgBox strResponse
        Sheets(1).Range("a1") = strResponse
       
    End With

End Sub
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
What's the value of the city variable?
 
Upvote 0
Actually, I've thought about it some more, and this is odd. I cannot reproduce that error with this code.

That error message occurs when you've directed it to a URL that simply doesn't exist - say, for example, https://www.mrexcel.com/iamcertainthatthisdoesnotexist.pdf But even if you do direct it to something that does not exist, most websites will at least return a Error 404 - Page Not Found result with HTML code to render saying that it couldn't find that page. That's the case with Mr Excel, and the same holds true for (really, anything to do with) wikipedia. So regardless of the value of the city variable, or whatever is in cell B1, it should at least return something.

Unless you're using it with a different URL or there is some other relevant code that is impacting the operation of your code, I'm afraid I have no idea. Hopefully someone more knowledgable than me can help out.
 
Upvote 0
Whichever city you want.

For instance:

That wasn't what I was asking - the question was driving at what you had in the city variable. As I have since explained, the point was that the error message indicates the URL you're using doesn't exist. The URL is constructed to include whatever you have at cell B1. I have since addressed this point in my second response.
 
Upvote 0

Forum statistics

Threads
1,214,614
Messages
6,120,517
Members
448,968
Latest member
Ajax40

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