TextRange.TrimText method (PowerPoint)

Returns a TextRange object that represents the specified text minus any trailing spaces.

Syntax

expression. TrimText

expression A variable that represents a TextRange object.

Return value

TextRange

Example

This example inserts the string " Text to trim " at the beginning of the text in shape two on slide one in the active presentation and then displays message boxes showing the string before and after it is trimmed.

With Application.ActivePresentation.Slides(1).Shapes(2) _
        .TextFrame.TextRange
    With .InsertBefore("   Text to trim   ")
        MsgBox "Untrimmed: " & """" & .Text & """"
        MsgBox "Trimmed: " & """" & .TrimText.Text & """"
    End With
End With

See also

TextRange Object

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.