Discussion Locked

VBA Macro message from word to outlook

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
How do I create a VBA macro to copy the message body in Microsoft Word to the message body in Microsoft Outlook? Are there VBA instructions to launch Microsoft Outlook and Microsoft Word? Is there a reference book of all VBA instructions?

3 replies

by irina medvinskaya

In your word document create a macro that will open an outlook application, create a new mail item and pass the selected text from word document to the outlook message item.
Your code in word would look like this:
[Go to Tools->References and check item Microsoft Outlook Object Library]

Private Sub CreateMailItem()
Dim sBodyText As String
Dim oOutlookApp As New Outlook.Application
Dim oMsg As Outlook.MailItem

'presuming you selected some text in Word
sBodyText = Selection.Text & ""

'Create a message.
Set oMsg =oOutlookApp.CreateItem(olMailItem)

With oMsg
.Body = sBodyText
.Display
End With

Set oOutlookApp = Nothing

End Sub

Good books for this are:
1.Microsoft Office 2000/Visual Basic Language Reference
2.Microsoft Office 2000/Visual Basic for Applications Fundamentals
3.Microsoft Office 2000 VBA Fundamentals/Mastering Solution Set
4.Microsoft Mastering: Microsoft Office 2000 Development

by hurdk

This code works very well.

I give the answer a very high rating.

In my case I had to shade the text initially. I had text form fields
in the document.

This discussion is closed to new replies.