Project) (ShapeRange.TextFrame2 属性

获取 TextFrame2 对象,该对象包含文本框架中的文本以及控制文本框架的对齐、定位和其他功能的成员。 只读 TextFrame2 对象。

语法

表达式。TextFrame2

表达式 表示 'ShapeRange' 对象的变量。

备注

TextFrame2 对象包含许多与 TextFrame 对象相同的属性,以及诸如自动调整、ThreeD 和艺术字格式等其他属性。

示例

以下示例创建两个文本框并将它们添加到 ShapeRange 对象中,设置两个文本框架以自动调整文本大小,将第一个文本框形状中文本的前景色设置为红色,将形状区域的前景色设置为黄褐色,然后使用 TextEffect 属性设置形状范围内两个文本框的字体属性。

ShapeRange 对象的 TextFrame2 属性以粗体显示。

Sub FormatTextBox()
    Dim theReport As Report
    Dim textShape1 As shape
    Dim textShape2 As shape
    Dim reportName As String
    Dim sRange As ShapeRange
    
    reportName = "Textbox range report"
    
    Set theReport = ActiveProject.Reports.Add(reportName)
    Set textShape1 = theReport.Shapes.AddTextbox(msoTextOrientationHorizontal, 30, 50, 350, 80)
    textShape1.Name = "Text box 1"
    
    Set textShape2 = theReport.Shapes.AddTextbox(msoTextOrientationHorizontal, 30, 130, 350, 80)
    textShape2.Name = "Text box 2"
    
    Set sRange = theReport.Shapes.Range(Array("Text box 1", "Text box 2"))
        
    sRange.TextFrame2.AutoSize = msoAutoSizeShapeToFitText
        
    sRange(1).TextFrame2.TextRange.Text = "This is a test. It's only a test."
    sRange(2).TextFrame2.TextRange.Text = "This is text box 2."
    sRange(1).TextFrame2.TextRange.Characters.Font.Fill.ForeColor.RGB = &H2020CC
    sRange.Fill.ForeColor.RGB = &H88CCCC
        
    With sRange.TextEffect
        .FontName = "Courier New"
        .FontBold = True
        .FontItalic = True
        .FontSize = 28
    End With
    
    sRange(2).Select
End Sub

属性值

TEXTFRAME2

另请参阅

ShapeRange 对象TextFrame2

支持和反馈

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