Table of contents
TOC
折叠目录
展开目录

ShapeRange.HasTextFrame 属性 (PowerPoint)ShapeRange.HasTextFrame Property (PowerPoint)

office 365 dev account|上次更新日期: 2018/3/13
|
2 参与人员

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

语法Syntax

表达式HasTextFrameexpression. HasTextFrame

表达式_一个表示一个ShapeRange对象的变量。_expression A variable that represents a ShapeRange 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

概念Concepts

绘图对象ShapeRange Object

© 2018 Microsoft