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

Nelson78

Active Member
Joined
Sep 11, 2017
Messages
488
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

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.

Dan_W

Active Member
Joined
Jul 11, 2018
Messages
444
Office Version
  1. 365
Platform
  1. Windows
What's the value of the city variable?
 

Dan_W

Active Member
Joined
Jul 11, 2018
Messages
444
Office Version
  1. 365
Platform
  1. Windows
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.
 

Dan_W

Active Member
Joined
Jul 11, 2018
Messages
444
Office Version
  1. 365
Platform
  1. Windows
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.
 

Watch MrExcel Video

Forum statistics

Threads
1,130,423
Messages
5,642,034
Members
417,251
Latest member
Dordrecht

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
Top