[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1178
  • Last Modified:

VB .net mshtml.HTMLDocument

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("http://www.yahoo.com", vbNullString)

Open in new window

0
disrupt
Asked:
disrupt
1 Solution
 
käµfm³d 👽Commented:
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)

        iPSI.InitNew()
        objDocument = objMSHTML.createDocumentFromUrl("http://www.yahoo.com", Nothing)

        Console.ReadKey()
    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

0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now