MiniG34
MiniG34

Reputation: 332

How to use an InternetExplorer.Application Object to open an HTMLDocument Object in VBA

In Access VBA, I would like to create an HTML Document Object and open it using an InternetExplorer.Application Object without having to save the HTML document. Is there something similar to the code below that could do the trick, knowing the code leads to a Run-time error '5': Invalid procedure call or argument.

Dim Explorer As Object
Dim HTMLDoc As HTMLDocument

Set HTMLDoc = CreateObject("htmlfile")
HTMLDoc.body.innerHTML = "<h1>This is a test.</h1>"
Set Explorer = CreateObject("InternetExplorer.Application")
Explorer.navigate HTMLDoc

Upvotes: 1

Views: 639

Answers (1)

Tim Williams
Tim Williams

Reputation: 166146

You don't need the intermediate htmlfile object

Dim Explorer As Object
Set Explorer = CreateObject("InternetExplorer.Application")
With Explorer
    .Visible = True
    .navigate "about:blank"
    .document.body.innerHTML = "<h1>This is a test.</h1>"
End With

Upvotes: 1

Related Questions