Text Selection

Add-in Express™ Support Service
That's what is more important than anything else

Text Selection
 
Chris Harris




Posts: 32
Joined: 2008-08-14
Hi guys,

Do you have an example of how I can get the selected text from an Outlook mail message when the message format is either Text or RTF and Word is not being used as the editor?

Also, In getting a text selection from Powerpoint - I have worked out how to get the selected text but would also like to get the word that the user has clicked on as well (as I can in Word). Any ideas? Here's the code:

String textToTranslate = String.Empty;
PowerPoint.TextRange range = null;

try
{
range = PowerPointApp.ActiveWindow.Selection.TextRange;
textSel = range.Text;
}

Thanks

Chris
Posted 30 Sep, 2008 06:50:30 Top
Eugene Astafiev


Guest


Hi Chris,

Unfortunately we don't have such a sample project.
Posted 30 Sep, 2008 07:37:09 Top
Chris Harris




Posts: 32
Joined: 2008-08-14
Thanks Eugene,

What about the PowerPoint problem?

Chris
Posted 30 Sep, 2008 10:36:05 Top
Eugene Astafiev


Guest


Chris,

Don't forget to release COM objects. In the code listed above you didn't release 3!!! COM objects:

1. ActiveWindow
2. Selection
3. TextRange

Could you describe the problem in more details?
Posted 30 Sep, 2008 17:12:51 Top
Chris Harris




Posts: 32
Joined: 2008-08-14
Thanks Eugene,

I do in my code routine - the snippet above was simply to illustrate! Thanks for the tip though ;-)

The problem is this: In Word, the Selection object is populated if the user right-clicks a word or selects (highlights) a word or words. I would like to achieve the same thing in PowerPoint. The code above only populates textSel if the user selects (highlights) a word or words - textSel is null if the user right-clicks a word.

I could probably get around it by making a series of API calls - just wondered if you had a simpler method - something I'm missing in the PowerPoint Object Model perhaps?

Cheers

Chris
Posted 01 Oct, 2008 06:40:32 Top
Eugene Astafiev


Guest


Hi Chris,

Unfortunately no. It seems you need to use some APIs calls.
Posted 01 Oct, 2008 07:01:34 Top