View Single Post
 
Old 09-04-2014, 07:01 AM
odin odin is offline Windows 7 64bit Office 2010 64bit
Novice
 
Join Date: Sep 2014
Posts: 11
odin is on a distinguished road
Default How to copy userform text and formfield contents to outlook?

I have a userform that has text and formfields mixed in. I would like to copy the text and the contents of the legacy formfields into an Outlook email message, while keeping the text formatting (bold, italic, underline, etc..). I did some research and found code that almost does what I need but it's pasting the formfield as a formfield and not as text.

Any help on how to modify the code to do this would be greatly appreciated.

Private Sub EmailData()
Dim OutApp As Object
Dim OutMail As Object
Dim OutInsp As Outlook.Inspector
Dim WdApp As Word.Application
Dim OutDoc As Word.Document
Dim WdSel As Word.Selection

Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
.To = "EmailAddressHere"
.Subject = "SubjectHere"
.Display
End With

Set OutInsp = OutMail.GetInspector
Set OutDoc = OutInsp.WordEditor
Set WdApp = OutDoc.Application
Set WdSel = WdApp.Selection

ActiveDocument.Content.Copy
WdSel.PasteAndFormat Type:=wdFormatOriginalFormatting

Set WdSel = Nothing
Set OutInsp = Nothing
Set OutMail = Nothing
Set OutDoc = Nothing
Set WdApp = Nothing
Set OutApp = Nothing
End Sub
Reply With Quote