Link to home
Start Free TrialLog in
Avatar of shacho
shacho

asked on

Getting Selected Text From Outlook

Is there any was to programatically get at whatever text is currently selected in Outlook?  I tried VBA.SendKeys "^c" as a last resort but even that didn't work.  Any ideas?

Mike
Avatar of Chris Bottomley
Chris Bottomley
Flag of United Kingdom of Great Britain and Northern Ireland image

Hello shacho,

Try the following code section .. it works on any mailitem but is defined here to work with the selected text in the open mailitem.

Regards,
Chris
Sub getsel()
Dim itm As Object
Dim insp As Inspector
Dim wd As Object 
    Set itm = Application.ActiveInspector.CurrentItem
    Set insp = itm.GetInspector
    Set wd = insp.WordEditor
    msgbox "Current Selection", wd.Windows(1).Selection
    
End Sub

Open in new window

Avatar of shacho
shacho

ASKER

That might work except I don't use word as my editor and the selected text is in the preview pane, not an open item.  As such there is no active inspector.  Any idea how to get at the preview pane?
ASKER CERTIFIED SOLUTION
Avatar of Chris Bottomley
Chris Bottomley
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of shacho

ASKER

Oh well.  Thanks for your comments.

Mike