Results 1 to 5 of 5
  1. #1
    5 Star Lounger AndrewKKWalker's Avatar
    Join Date
    Apr 2001
    Location
    Cambridge, UK
    Posts
    1,020
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Copy data in HTML format from Excel -Outlook Mail (Excel 2007 )

    Is there any way to get a block of cells from Excel into an Outlook Mail Item using VBA
    as a copy and paste exercise without trying to use for example sendkeys.

    I can do the exercise using VBA by reading the relevant cells and writing them
    into the Outlook body text area using a loop against the range,
    but what I would like to do is either
    a. Transfer them as a block (either HTML or Image)
    OR as a word style table.
    Can't figure if this is even possible, but it is as a manual exercise.
    I can do it in Word no problem by creating a table and then poulating it, but in Outlook ????

    Anyone done this?
    Andrew

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Copy data in HTML format from Excel -Outlook Mail (Excel 2007 )

    Do you just want to get the values into the e-mail, or should the formatting (fonts, alignment, colors, borders, shading) be preserved?

  3. #3
    5 Star Lounger AndrewKKWalker's Avatar
    Join Date
    Apr 2001
    Location
    Cambridge, UK
    Posts
    1,020
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: Copy data in HTML format from Excel -Outlook M

    I can get the data across in a text format by just reading the cells and writing them to the body text.
    I can also use functiions like format to try and preserve some semblance of the formatting.
    BUT you question is correct in its assumption.
    What I'd ideally like to do is to get the data across with all it's formatting in tact.
    I can live with a bit of a loss within the limitations of HTML if needed.
    I could create an image and save the file but then as far as I can see I'd have to attach it.
    I could also obviously just create temp files from data and attach them,
    but I'd like the formatted data embedded in the body of the email.

    Just wondered if it was possible.
    Andrew

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Copy data in HTML format from Excel -Outlook M

    See Excel to HTML conversions; this page describes VBA code to convert the selected range into an HTML file. There is a link to the actual code.

    You can open the resulting HTML file as a text file and extract the part from <table ...> to </table>, and insert this into the HTMLBody property of your e-mail, or you can modify the XL2HTML_Main procedure to produce a string instead of a file.

  5. #5
    5 Star Lounger AndrewKKWalker's Avatar
    Join Date
    Apr 2001
    Location
    Cambridge, UK
    Posts
    1,020
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: Copy data in HTML format from Excel -Outlook M

    Thanks Hans.
    Looks like I've got a bit of reading to do.
    Still, I did ask.
    Now having seen the example I can see the basic principle of generating the HTML as well.
    So, lot's of ideas now.

    Thanks again.
    Andrew

Posting Permissions

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