4

I'd like to load a string as an html file using MSHTML in VBScript and parse it. I can do this with "InternetExplorer.application" but I'd like to do it with "htmlfile" (MSHTML.HTMLDocument)

The following code:

Set h =  CreateObject("htmlfile")
h.body.innerHTML = "html goes here"

gives this error:

Microsoft VBScript runtime error: Object required: 'body'

How do I load the html string?

Eugene
  • 10,957
  • 20
  • 69
  • 97

1 Answers1

5

Probably cheating, but seems to work:

  Dim oHF : Set oHF = CreateObject("HTMLFILE")
  oHF.write "<html><body></body></html>"
  oHF.body.innerHTML = "<p>WhatEver</p>"
  WScript.Echo oHF.body.innerTEXT
Ekkehard.Horner
  • 38,498
  • 2
  • 45
  • 96
  • That works! However, when I user .write, it automatically loads all the related .css and .js files (which sit on other urls), but not the images. Additionally, it also loads the background images listed in the .css (which is probably a glitch). Do you know how to prevent the loading of external resources? – Eugene Mar 29 '12 at 22:41