PDA

View Full Version : Putting Tabled Outlook Date Into Clipboard



Jhorst
10-19-2007, 03:57 PM
Hello,
I?m currently working on a project to pull data out of an outlook 2003 email and copy it to the clipboard for use in Word. The information is presented in a table that when copied manually will drop directly into word with the formatting intact for me to manipulate there, however when I try to automate with a macro doing the select all and copy action, the formatting is completely dropped. Here is what I have:

Sub Pull()
Dim dataobj As DataObject
Dim olExp As Explorer
Dim olMail As mailItem
Set olExp = Application.ActiveExplorer
Set olMail = olExp.Selection.Item(1)
Set dataobj = New DataObject
With dataobj
.ClearTest1
.SetText olMail.Body
.PutInClipboard
End With

End Sub

Thanks,
John

mvidas
10-24-2007, 11:49 AM
Hi John,

The DataObject can only store text and not formatting; so when you add the olMail.Body to the clipboard it is only storing the flat text. Since your data is in a table it is likely in HTML Format, try using .SetText olMail.HTMLBody instead, should give you the results you're looking for. Otherwise you could always save the email as an .html file and open that in Word.