VBA TIPS
Using Microsoft XMLHTTP Object to get HTML source from a web

what is XML? What is MSXML?

XML stands for Extensible Markup Language. XML is the very flexible syntax which can be used in order to explain the information on all kinds on the substance which can be saved to a computer.

The information included in the XML document is easily passed between application and a system. MSXML is the set of the service which offers the function for treating an XML document, and MSXML is enclosed by the following Microsoft product. Microsoft Windows XP Microsoft Internet Explorer 6.0 Microsoft SQL Server 2000.

The following code get the HTML source from my website and print it in the immediate window.



Option Explicit

Sub GetHtmlWithXML()
    Const sURI As String = "http://www.puremis.net/excel/"
    Dim oHttp As Object

    ' Create an XMLHTTP object
    On Error Resume Next
    Set oHttp = CreateObject("MSXML2.XMLHTTP")
    If Err.Number <> 0 Then
        Set oHttp = CreateObject("MSXML.XMLHTTPRequest")
    End If
    On Error GoTo 0
    If oHttp Is Nothing Then
        Exit Sub
    End If

    ' If domain needs ID and Password use thw code below
    ' oHttp.Open "GET", strURI, False, "DomainName\UserID", "PassWord"
    oHttp.Open "GET", sURI, False
    oHttp.Send
    Debug.Print oHttp.responseText
    Set oHttp = Nothing
End Sub



| HOME |
Copyright © cellmasters.net - colo's junk room All Right Reserved
ABOUT
WORKS
THE CELL MASTERS
CONTACT
LINKS
Tips and Information about Microsoft Excel|Masaru Kaji aka Colo