ShapeRange.HasTextFrame 属性 (PowerPoint)

返回指定的形状是否有文本框架。 只读。

语法

expressionHasTextFrame

表达 一个代表 ShapeRange 对象的变量。

返回值

MsoTriState

备注

HasTextFrame 属性的值可以是其中一个 MsoTriState 常量。

常量 说明
msoFalse 指定的形状没有文本框架,因而不能包含文本。
msoTrue 指定的形状有文本框架,因此可包含文本。

示例

下面的例子从第一张幻灯片上所有包含文本框的形状中提取文本,然后将这些形状的名称及其所包含的文本保存在一个数组中。

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

另请参阅

绘图对象

支持和反馈

有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。