VBA find and replace images in Word document

I have an existing VB 6 application that opens an HTML document in Microsoft Word.  When the user is finished with the document, the application converts the HTML file to a .doc, using wdFormatDocument in the SaveAs command to ensure it is saved as a Word Document file.  The issue is the images.  They are displaying fine in the HTML file being displayed in Word, however, after saving and closing the file and reopening the .doc file, they no longer display, just a red x placeholder is displayed.  It appears, even though the file is converted to the Word Document format, it still wants to use the HTML references to point to the images in the file instead of embedding them in the Word Document.

To get around this the user needs to use "Insert...\Picture...\From File" and in effect replace the image with the same image again.  Then it works fine after my VB application saves it as a Word Document.  When the Word Document, .doc file is opened the images display fine.

My question is one or the other here.  Is there a way to tell Microsoft Word when it saves the HTML document as a Microsoft Word Document to embed the images in the .doc file?  Either that, or is there a way to search through the HTML document in Word and find each image and replace it with the same image file again?

Thank you for your help and suggestions.
LVL 3
ironcladsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

irudykCommented:
Try unlinking the images and then save as a Word document.  Try incorporating something like the following code into your existing routine:
Dim f As Word.Field
For Each f In ActiveDocument.Fields
    If f.Type = wdFieldIncludePicture Then f.Unlink
    'or
    'If f.Type = 67 Then f.Unlink
Next

'save file as a .doc

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ironcladsAuthor Commented:
Hard to believe it's that simple.  Cool!  It worked like a charm.  Thanks.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.