I have created a Word template that uses a userform - a date field, some list boxes, some text boxes, etc. Then, when user is done, there are command buttons that call various vba subs - one is "InsertData" which does exactly what I want - which is to take the user input and place it in appropriate positions in a table (yes, I am intentionally using Word rather than Excel - truthfully I am taking a custom routine from Excel and trying to create it in Word, and it was much easier to set up in Excel!). Then, I want to "EmailData" - where the entire text of the document is placed into the body of a new message window, while holding its table format, with To and Subject prefilled, but display only (user will need to select attachments before sending). Then, the userform is unloaded, and the Word document will close without saving (or prompting to save).
Everything works great, except that the formatting is not retained. I've tried various paste methods and range selection methods, and I can't find one that works. (Note that if I Ctrl+V in the Outlook message window after the code has run (when I have the Range.Copy line included), it pastes exactly as I want it - is there any way to paste clipboard, or even push the keystrokes to the message window??) Any help would be appreciated. My "Email Data" code is below.
Private Sub EmailData()
Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
.To = "EmailAddressHere"
.Subject = "SubjectHere"
.HTMLBody = ActiveDocument.Range.FormattedText
Set OutMail = Nothing
Set OutApp = Nothing