I have been unable to find code to allow me to get the highlighted (selected) text portion from an outlook email body and assign it to vba string variable so I can use it in excel vba code function.
My process would be something like:
1. Select text string in the format like xxxx-xxx
2. Press button in excel form
3. Get the selected outlook text string
4. Pass the text string to an excel vba function that I already have.
I seem to be able to get the whole email body but not the selected/highlighted text.
sub test
Dim OutApp As Object
Dim OutMail As Object
Dim msgbody As String
Dim Selection As String
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.ActiveInspector.CurrentItem
msgbody = OutMail.Body
Selection = OutMail.Selection
Debug.Print Selection
Set OutMail = Nothing
Set OutApp = Nothing
end sub