+ Reply to Thread
Results 1 to 3 of 3

Macro to body of email from word & excel - can't get HTML format correct

  1. #1
    Registered User
    Join Date
    09-29-2012
    Location
    Midwest, USA
    MS-Off Ver
    Excel 2007
    Posts
    2

    Macro to body of email from word & excel - can't get HTML format correct

    I am trying to wite a macro that will allow us to create ad-hoc reports from data in excel. This macro will create an email for every unique code in column A. I then create the body of the email by pulling the info from a word file then adding the excel data.

    The excel data is in HTML and looks great. The problem is that I cannot get any formatting for the word doc. Is there anyway of getting it to convert the word into HTML?

    This is what it looks like (BTW - The formating for the excel part is fine) It's just the part that comes from word) I also attached my word doc and my excel data

    This is a test Good Job So Long

    Bob Johnson

    CarrierPar
    Carrier PctAward Freq EffDate AAWV TempPro
    DestCity DestSt ######## ######## ######## ######## 1/0/1900 1/0/1900 1/0/1900 1/0/1900
    BBBBB CRCR 1 WEEK ######## 4.9 N/A MIDWAY TN 2.00 0.0 2.0 0.0 0 0 0 0


    This is what I want it to look like

    This is a test
    1. Good Job
    2. So Long

    Bob Johnson

    CarrierPar
    Carrier PctAward Freq EffDate AAWV TempPro
    DestCity DestSt ######## ######## ######## ######## 1/0/1900 1/0/1900 1/0/1900 1/0/1900
    BBBBB CRCR 1 WEEK ######## 4.9 N/A MIDWAY TN 2.00 0.0 2.0 0.0 0 0 0 0



    Please Login or Register  to view this content.
    Thanks
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    05-21-2009
    Location
    Great Britain
    MS-Off Ver
    Excel 2003
    Posts
    550

    Re: Macro to body of email from word & excel - can't get HTML format correct

    Quote Originally Posted by MacroMess View Post
    The excel data is in HTML and looks great. The problem is that I cannot get any formatting for the word doc. Is there anyway of getting it to convert the word into HTML?

    .HTMLBody = strbody & RangetoHTML(newRng)
    RangeToHTML returns a complete HTML document string with <html> and <body> tags, so you need to insert the Word text inside the <body> tag. I'm guessing that the above line is inserting strbody before the HTML, so creating an invalid HTML document. To insert within the <body> tag try something like this (put the lines in the appropriate places in your code):
    Please Login or Register  to view this content.
    You might need to put paragraph tags (<p>) around MsgTxt
    Post responsibly. Search for excelforum.com

  3. #3
    Registered User
    Join Date
    09-29-2012
    Location
    Midwest, USA
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Macro to body of email from word & excel - can't get HTML format correct

    Chippy

    Thanks for your help. That's worked. The only difference is that I used <pre> tags instead of the <p> tag

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1