The following will get the currently selected text from an e-mail message in Outlook. If you are familiar with Word VBA then wdDoc is the message body and can be processed pretty much as a document in Word.
Sub test() Dim OutApp As Object Dim OutMail As Object Dim olInsp As Object Dim wdDoc As Object Dim strText As String On Error Resume Next 'Get Outlook if it's running Set OutApp = GetObject(, "Outlook.Application") 'Outlook wasn't running, so cancel If Err <> 0 Then MsgBox "Outlook is not running so nothing can be selected!" GoTo lbl_Exit End If On Error GoTo 0 Set OutMail = OutApp.ActiveExplorer.Selection.Item(1) With OutMail Set olInsp = .GetInspector Set wdDoc = olInsp.WordEditor strText = wdDoc.Application.Selection.Range.Text End With MsgBox strText lbl_Exit: Set OutMail = Nothing Set OutApp = Nothing Set olInsp = Nothing Set wdDoc = Nothing Exit Sub End Sub




Reply With Quote