VB .net mshtml.HTMLDocument

Posted on 2011-05-04
Last Modified: 2012-05-11
I tried the following below but get a AccessViolationException.  How can I create an HTMLDocument off a URL?
Dim objMSHTML As New mshtml.HTMLDocument
Dim objDocument As mshtml.HTMLDocument

objDocument = objMSHTML.createDocumentFromUrl("", vbNullString)

Open in new window

Question by:disrupt
    1 Comment
    LVL 74

    Accepted Solution

    According to the information in this post, you should do something like this:
    Imports System.Runtime.InteropServices
    Module Module1
        Sub Main()
            Dim objMSHTML As New mshtml.HTMLDocument
            Dim objDocument As mshtml.HTMLDocument
            Dim iPSI As IPersistStreamInit = DirectCast(objMSHTML, IPersistStreamInit)
            objDocument = objMSHTML.createDocumentFromUrl("", Nothing)
        End Sub
    End Module
    <ComVisible(True), ComImport(), Guid("7FD52380-4E07-101B-AE2D-08002B2EC713"), InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)> _
    Public Interface IPersistStreamInit
        Sub GetClassID(ByRef pClassID As Guid)
        <PreserveSig()> Function IsDirty() As Integer
        <PreserveSig()> Function Load(ByVal pstm As UCOMIStream) As Integer
        <PreserveSig()> Function Save(ByVal pstm As UCOMIStream, ByVal ByValByValfClearDirty As Boolean) As Integer
        <PreserveSig()> Function GetSizeMax(<InAttribute(), Out(), MarshalAs(UnmanagedType.U8)> ByRef pcbSize As Long) As Integer
        <PreserveSig()> Function InitNew() As Integer
    End Interface

    Open in new window


    Featured Post

    Live: Real-Time Solutions, Start Here

    Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

    Join & Write a Comment

    This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
    I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now