HasTextFrame 属性 (PowerPoint)Shape.HasTextFrame property (PowerPoint)

返回指定的形状是否有文本框架。Returns whether the specified shape has a text frame. 此为只读属性。Read-only.

语法Syntax

expressionexpression. HasTextFrame

_表达式_一个代表**Shape** 对象的变量。expression A variable that represents a Shape object.

返回值Return value

MsoTriStateMsoTriState

备注Remarks

HasTextFrame属性的值可以是下列MsoTriState常量之一。The value of the HasTextFrame property can be one of these MsoTriState constants.

常量Constant 说明Description
msoFalsemsoFalse 指定的形状没有文本框架,因而不能包含文本。The specified shape does not have a text frame and therefore cannot contain text.
msoTruemsoTrue 指定的形状有文本框架,因此可包含文本。The specified shape has a text frame and can therefore contain text.

示例Example

下面的例子从第一张幻灯片上所有包含文本框的形状中提取文本,然后将这些形状的名称及其所包含的文本保存在一个数组中。This example extracts text from all shapes on the first slide that contain text frames, and then it stores the names of these shapes and the text they contain in an array.

Dim shpTextArray() As Variant

Dim numShapes, numAutoShapes, i As Long



Set myDocument = ActivePresentation.Slides(1)

With myDocument.Shapes
    numShapes = .Count
    If numShapes > 1 Then
        numTextShapes = 0
        ReDim shpTextArray(1 To 2, 1 To numShapes)
        For i = 1 To numShapes
            If .Item(i).HasTextFrame Then
                numTextShapes = numTextShapes + 1
                shpTextArray(numTextShapes, 1) = .Item(i).Name
                shpTextArray(numTextShapes, 2) = .Item(i) _
                    .TextFrame.TextRange.Text
            End If
        Next
        ReDim Preserve shpTextArray(1 To 2, 1 To numTextShapes)
    End If
End With

另请参阅See also

形状对象Shape Object

支持和反馈Support and feedback

有关于 Office VBA 或本文档的疑问或反馈?Have questions or feedback about Office VBA or this documentation? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.