Get selection into textstring

P

Peter R.

How do I get a marked piece of text in a email into a string in my VBA ?
Thanks Peter.
 
S

Sue Mosher [MVP-Outlook]

Marked where? Reading pane? Open Inspector window? In what version of Outlook?
 
S

Sue Mosher [MVP-Outlook]

In what version of Outlook? In a received message? Message in the process of being composed?

What format message -- HTML, RTF, plain text?

All these details matter.

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
 
P

Peter R.

Thanks again Sue.

It´s Outlook 2007, it´s a received message in the Inbox.
 
S

Sue Mosher [MVP-Outlook]

That's the easiest scenario to handle, because Word is always the email editor in Outlook 2007:

Set objOL = Outlook.Application
Set objDoc = objOL.ActiveInspector.WordEditor
Set objWord = objDoc.Application
Set objSel = objDoc.Windows(1).selection
MsgBox objSel.Text
 
P

Peter R.

thanks a lot!

Sue Mosher said:
That's the easiest scenario to handle, because Word is always the email editor in Outlook 2007:

Set objOL = Outlook.Application
Set objDoc = objOL.ActiveInspector.WordEditor
Set objWord = objDoc.Application
Set objSel = objDoc.Windows(1).selection
MsgBox objSel.Text

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
 
P

Peter R.

One more question, could this be any different in Outlook 2003 ? Thanks again!
 
S

Sue Mosher [MVP-Outlook]

Outlook 2003 would be completely different, since the only time when Word would be used is if the message is in RTF format and Word is the editor. In fact, to get the selection from a received plain text message, you'd need a third-party library (Redemption).

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
 
Top