View Full Version : Copying HTML formatted text from word to an outlook message

10-14-2004, 06:21 AM
A pesky little problem which has buggered me for a couple of hours.

I've written code to automate a word document and an outlook message, copy the contents of the word document to the outlook message and then send it. I'm running the code from Excel.

I want to format the outlook message as HTML but so far I've been unable to format the text and I don't want to resort to API calls to dump the clipboard contenets

I've formatted the message as
.BodyFormat = olFormatHTML
and this opens Word as my default editor

But at the moment I cant get VBA to do the same formatting job as a simple manual copy and paste



10-14-2004, 11:02 AM
Hi Dave,

I had a play with this a couple of weeks back but can't remember all the details, but a couple of possibilities, until a real expert comes along:

If you have Word open as an editor inside Outlook you should be able to use GetObject to address it (provided you don't have other instances of Word open at the same time)

Alternatively, if you save your Word document as HTML and then open the .htm file using OpenAsTextStream, read the whole thing into a string variable, you should then be able to set the .HTMLBody of the message to it.

I'll root out a bit of code if you like