I am writing some VBA code which manipulates an HTML document. The document is opened as text so that the HTML can be worked on. Thus:
Dim oWordDoc As Word.Document
Set oWordDoc = Documents.Open(FileName:=strFolder & "\" & strFileName, _
Format:=wdOpenFormatText)
The HTML contains some meta tags that I would like to be able to access by ID. This is the code I tried to attempt this:
Dim objHtmlDoc As HTMLDocument
Dim objMetaTag As HTMLMetaElement
Set objHtmlDoc = oWordDoc
Set objMetaTag = objHtmlDoc.getElementById("keywords")
However, I get a Type Mismatch error on the line:
Set objHtmlDoc = oWordDoc
I tried to set the objHtmlDoc to oWordDoc.content, and get the same error. Is there anyway that I can convert the Word.Document object to an HTMLDocument object so that I can set the HTMLDocument to be the Word.Document? Or will I have to develop my own getElementbyID function to perform this?
Thanks.
An Alternative that I was suggesting.