Project) (Shape.TextFrame2 屬性

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

語法

運算式。TextFrame2

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

註解

TextFrame2 物件包含許多與 TextFrame 物件相同的屬性,以及其他屬性,例如 AutoSize、ThreeD 和 WordArtformat。

範例

下列範例會建立兩個文字方塊,並將它們新增到 ShapeRange 物件中、設定兩個文字框都自動符合文字大小、將第一個文字方塊圖形中文字的前景色設定為紅色、將圖形範圍的前景色設定為黃褐色,然後使用 TextEffect 屬性設定圖案範圍內兩個文字方塊的字型屬性。

個別 Shape 物件的 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

另請參閱

圖形物件TextFrame2

支援和意見反應

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