共用方式為


Shape.TextFrame2 屬性 (專案)

取得一個 TextFrame2 物件,包含文字框架中的文字,以及控制對齊、錨定和其他文字框架功能的成員。 唯讀的 TextFrame2

語法

表情TextFrame2

expression 一個用於表示 Shape 物件的變數。

註解

TextFrame2 物件包含許多與 TextFrame 物件相同的屬性,並附加 AutoSizeThreeDWordArtformat 等額外屬性。

範例

以下範例建立兩個文字框並將它們加入 ShapeRange 物件,設定兩個文字框自動符合該文字,將第一個文字框形狀的前景色設定為紅色,將形狀範圍的前景色設定為偏黃褐色,然後使用 TextEffect 屬性在形狀範圍內的兩個文字框上設定字體屬性。

TextFrame2 屬性以粗體顯示,針對各個 Shape 物件。

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

另請參閱

形狀物件TextFrame2

支援和意見反應

有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應