Muokkaa

Jaa


TextRange.Runs method (PowerPoint)

Returns a TextRange object that represents the specified subset of text runs. A text run consists of a range of characters that share the same font attributes.

Syntax

expression. Runs( _Start_, _Length_ )

expression A variable that represents a TextRange object.

Parameters

Name Required/Optional Data type Description
Start Optional Long The first run in the returned range.
Length Optional Long The number of runs to be returned.

Return value

TextRange

Remarks

If both Start and Length are omitted, the returned range starts with the first run and ends with the last paragraph in the specified range.

If Start is specified but Length is omitted, the returned range contains one run.

If Length is specified but Start is omitted, the returned range starts with the first run in the specified range.

If Start is greater than the number of runs in the specified text, the returned range starts with the last run in the specified range.

If Length is greater than the number of runs from the specified starting run to the end of the text, the returned range contains all those runs.

A run consists of all characters from the first character after a font change to the second-to-last character that has the same font attributes. For example, consider the following sentence:

This italic word is not bold.

In the preceding sentence, the first run consists of the word "This" only if the space after the word "This" isn't formatted as italic (if the space is italic, the first run is only the first three characters, or "Thi"). Likewise, the second run contains the word "italic" only if the space after the word is formatted as italic.

For information about counting or looping through the runs in a text range, see the TextRange object.

Example

This example formats the second run in shape two on slide one in the active presentation as bold italic if it is already italic.

With Application.ActivePresentation.Slides(1).Shapes(2) _
        .TextFrame.TextRange

    With .Runs(2).Font
        If .Italic Then
            .Bold = True
        End If
    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.