2

I would like to select all characters in a Powerpoint textbox (Version 2010) that have a certain defined style (e.g. all bold characters). Manually, one can create a non-contiguous text selection in a single text box by simply holding the control key while selecting. With VBA, I failed so far. This is my very simple approach:

 Dim c As TextRange
 For Each c In ActiveWindow.Selection.ShapeRange(1).TextFrame.TextRange.Characters
  If c.Font.Bold Then c.Select
 Next c

While this all works nicely when going through this stepwise, the c.Select will always "unselect" what was selected before and there is no option to extend the selection (unlike with shape selections). I end up with just the last bold character being selected.

The selection itself is what I want as end result to give the user the option to further modify the font etc.

Does anyone have a suggestion (or is this not at all accessible via VBA?)

Thanks a lot

Tom Kinzel
  • 21
  • 1
  • Just a question, what would be the purpose of the noncontiguous text selection? are you doing some text formatting? If so you can do it one character at a time. so for example `If c.Font.Bold Then c.Font.Italic` – Jeanno Sep 29 '15 at 16:38
  • 1
    Thanks for the question; I would like to give the user the option to select one character in the text and then have VBA automatically select all other characters that have the same format as the one they chose (bold/color/font size etc). That way they can then reformat to their needs, e.g. set another font color. Basically, helping the user with the selection process. – Tom Kinzel Sep 29 '15 at 17:39
  • I dont think this is possible via VBA (although I think the idea is cute). I think the control key is there best friend. – Jeanno Sep 29 '15 at 19:45
  • OK, thanks. Too bad there are things that cannot be controlled via VBA... – Tom Kinzel Oct 01 '15 at 10:59

0 Answers0