Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8168823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T20:39:18+00:00 2026-06-06T20:39:18+00:00

I am writing some VBA code which manipulates an HTML document. The document is

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T20:39:19+00:00Added an answer on June 6, 2026 at 8:39 pm

    An Alternative that I was suggesting.

    Sub Sample()
        Dim objHtmlDoc As HTMLDocument
        Dim objMetaTag As HTMLMetaElement
        Dim IE As Object
    
        Set IE = CreateObject("InternetExplorer.Application")
        IE.Visible = True
    
        IE.navigate "C:\Sample.Htm"
    
        Set objHtmlDoc = IE.Document
        Set objMetaTag = objHtmlDoc.getElementById("keywords")
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing some code (just for fun so far) in Python that will store
I'm currently writing a code in VBA to retrieve prices for some financial models.
Part of some vba code I'm writing calls a saved import using: DoCmd.RunSavedImportExport import_name
I'm writing some python code that's supposed to parse a CSV file. Calculate the
Writing some docs with code snippets which I want to be copyable to run
I'm writing some code in Scala that depends a the type parameter that I
I'm writing some code in Visual Basic 6 and I have noticed that I
While writing some C code, I decided to compile it to assembly and read
I'm writing some test cases, and I've got a test case that is using
Writing some drag&drop code, I'd like to cancel the click events in my mouseup

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.