Skip to content Skip to sidebar Skip to footer

Cannot Call The Body Property For "htmlfile" Object In Vbscript

I have a VBSCript File that uses the MSXML2 library to get a response from a website; i'm trying to write that response to an HTMLFile object's body's innerHTML; although the objec

Solution 1:

You should initialize DOM first:

Set document = CreateObject("htmlfile")
document.write "<html><head><title>test</title></head><body><div>content</div></body></html>"
MsgBox document.body.innerHTML

Or

Set document = CreateObject("htmlfile")
document.open
document.close
document.body.innerHTML = "<html><head><title>test</title></head><body><div>content</div></body></html>"
MsgBox document.body.innerHTML

Note, that <html><head><title>test</title></head><body><div>content</div></body></html> just an example, you may use even empty string.

Post a Comment for "Cannot Call The Body Property For "htmlfile" Object In Vbscript"