PDA

View Full Version : Insert table result wrong layout



Tinbendr
09-02-2009, 06:22 AM
OK gang, what am I missing?

I have a report to send via email. This report is written in Word. I have a macro in Word that emails the Activedocument as an attachment. In this document, Table 1 is a summary of the document. I'd like to insert table 1 in the body for quick viewing by the recepient.

However, when I insert the table with
.Body = "Subject says it all!" & vbCr & ActiveDocument.Tables(1).Range
of course all the formatting is lost. It's laid out in a one column per line. Readable, but not what I'm looking for.

So when I insert the table with


.BodyFormat = olFormatHTML
.HTMLBody = "<b>Subject says it all!</b>" & vbCr & ActiveDocument.Tables(1).Range


Again, I lose all formatting and all of the text is scrunched together, with the white square boxes at the end of the lines. Very unreadable.

So I ask, what am I missing?

Thanks in advance!

JP2112
09-02-2009, 01:04 PM
Outlook version?

Have you tried using HTML and BODY tags with the HTMLBody property, a la the sample code found here? http://msdn.microsoft.com/en-us/library/aa211430(office.11).aspx

Tinbendr
09-02-2009, 01:55 PM
Outlook 2003.

Your suggestion didn't work.

.HTMLBody = "<HTML><H2>The body of this message will appear in HTML.</H2><BODY>" _
& ActiveDocument.Tables(1).Range & "</BODY></HTML>"


I'm close with this though.

'Set body format to HTML
ActiveDocument.Tables(1).Range.Copy

.BodyFormat = olFormatHTML
.HTMLBody = "<b>Subject says it all!</b><p>"
Set FndCtl = oItem.ActiveExplorer.CommandBars.FindControl(, 22) '&Paste