Search code examples
vbavstopowerpoint

Format multiple text selections in PowerPoint


I'm trying to see if there is a way to programmatically access multiple text selections in shapes/textboxes in PowerPoint.

The scenario is this - create a textbox that has the words "one two three" inside. Now, with the Ctrl button held down, select the words "one" and "three" (but not "two").

The ActiveWindow.Selection.TextRange and ActiveWindow.Selection.TextRange2 objects only provide a single selection. I was hoping it would provide both selections, like in a series of Runs, Paragraphs or whatnot. The ActiveWindow.Selection.ShapeRange object doesn't provide anything on this well - it's still a single shape.

In the PPT client, when you have multiple (disconnected) text selections, you can perform the same actions on them, like setting the font color to red. I'm looking for the same access, but programmatically - VBA, C#/VB.NET, VSTO, - any of those technologies are fine if you have a way to do this.


Solution

  • You cannot do it because of lack of support in the object model. Take a look at this kb article - https://social.msdn.microsoft.com/Forums/office/en-US/98c90979-fff7-4d0f-9499-6e6e730d9ea4/disjoint-selection-of-text?forum=worddev. Though it pertains to Word, the limitations are similarly applicable to PowerPoint.