Results 1 to 1 of 1
  1. #1
    New Lounger
    Join Date
    Feb 2011
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Excel macro to get HTTP source via MSXML2.XMLHTTP

    I submitted a question yesterday w/title Excel vba to get IE source. I had a working
    solution using MSXLM2.XMLHTTP to read the source without opening IE (or FireFox).
    The site did an upgrade so now the source received indicates the requested page
    requires an up-to-date viewer. So, as an alternate to yesterday's question, can this
    be changed so as to fake the source to appear as submitted by Firefox?

    Code:
     Public Sub ShowHTML(ByVal strURL)
    'Copied from http://stackoverflow.com/questions/2520949/getting-html-source-with-excel-vba
        On Error GoTo ErrorHandler
        Dim strError As String
        strError = ""
        Dim oXMLHTTP As MSXML2.XMLHTTP
        Set oXMLHTTP = New MSXML2.XMLHTTP
        strResponse = ""
        With oXMLHTTP
            .Open "GET", strURL, False
            .sEnd ""
    ...
            strResponse = .responseText
    ...
    Open has the following arguments:

    Sub open(bstrMethod As String, bstrUrl As String, [varAsync], [bstrUser], [bstrPassword])


    There is also

    Sub setRequestHeader(bstrHeader As String, bstrValue As String)

    that might be helpful.
    Last edited by Buford Carter; 2013-09-19 at 19:47.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •