• Excel macro to get HTTP source via MSXML2.XMLHTTP

    Home » Forums » AskWoody support » Productivity software by function » Visual Basic for Applications » Excel macro to get HTTP source via MSXML2.XMLHTTP

    Author
    Topic
    #491082

    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.

    Reply To: Excel macro to get HTTP source via MSXML2.XMLHTTP

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: