Artur_Hellmann's avatar
Artur_Hellmann
Iron Contributor
Mar 24, 2025
Status:
New

PowerPoint TextRange divide by formatting

If a TextRange has multiple formats (for example the first word is bold), it is currently not possible to get subTextRanges by the formatting.

For example if I only want to replace the bold word in a textrange, I currently have to instruct the user to mark it, so I can replace the text in the selected TextRange. 

Let's say I have this text:

This is an example with bold and italic text passages.

What I need is to get a list of TextRanges. Let's say a method named `splitByFormatting()`.

This would return a list of TextRanges:

[
    {
        text: "This is an ",
        ...
    } ,
    {
        text: "example",
        ...
    } ,
    {
        text: " with bold and ",
        ...
    } ,
    {
        text: "italic",
        ...
    } ,
    {
        text: " text passages.",
        ...
    } 
]


That way I can check what passage is the bold one and replace the text. Or I can have an programmatic overview over the formatting of the text.

1 Comment

  • By the way, in the current preview version I see there is a TextRun interface, but only for table cells. Not yet for TextRange or TextFrame