Xmlhttp request is raising an Access Denied error

后端 未结 9 1854
礼貌的吻别
礼貌的吻别 2020-12-03 21:48

The following Excel macro, which is making an xmlhttp request to this webpage to retrieve some values at a second stage, has worked normally in VBA until some time ago:

相关标签:
9条回答
  • 2020-12-03 22:05

    I'm afraid I don't understand exactly why this problem occurs, but I'm guessing it is the secure "https://" versus insecure "http://". I ran into the same "access denied" message while following sample code from a VBA course. The original code was:

    XMLPage.Open "GET", "http://x-rates.com/table/?from=GBP&amount=3", False    
    XMLPage.send
    

    I changed the "http://" to "https://" and the error went away.

    0 讨论(0)
  • 2020-12-03 22:13

    This works for me:

    With CreateObject("MSXML2.ServerXMLHTTP.6.0")
      .Open "GET", URL, False
      .Send
      content = .ResponseText
    End With
    
    0 讨论(0)
  • 2020-12-03 22:17

    Use

    CreateObject("MSXML2.ServerXMLHTTP.6.0") 
    

    The standard request fired from a local machine forbids access to sites that aren't trusted by IE. MSXML2.ServerXMLHTTP.6.0 is the server-side object, that doesn't perform those checks.

    0 讨论(0)
提交回复
热议问题