Consulting

Results 1 to 2 of 2

Thread: Copying HTML formatted text from word to an outlook message

  1. #1
    Knowledge Base Approver VBAX Expert brettdj's Avatar
    Joined
    May 2004
    Location
    Melbourne
    Posts
    649
    Location

    Copying HTML formatted text from word to an outlook message

    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

    Cheers

    Dave

  2. #2
    VBAX Master TonyJollans's Avatar
    Joined
    May 2004
    Location
    Norfolk, England
    Posts
    2,291
    Location
    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
    Enjoy,
    Tony

    ---------------------------------------------------------------
    Give a man a fish and he'll eat for a day.
    Teach him how to fish and he'll sit in a boat and drink beer all day.

    I'm (slowly) building my own site: www.WordArticles.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •