ShapeRange.TextFrame2 属性 (Project)

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

语法

表达式TextFrame2

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

备注

TextFrame2 对象包含许多与 TextFrame 对象相同的属性,以及 AutoSizeThreeD艺术字格式等其他属性。

示例

以下示例创建两个文本框并将其添加到 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 支持和反馈,获取有关如何接收支持和提供反馈的指南。