Shape.TextFrame2 屬性 (Project)
取得 TextFrame2 物件,其中包含文字圖文框中的文字,以及控制文字圖文框對齊、錨定和其他功能的成員。 唯讀的 TextFrame2 。
語法
運算式。TextFrame2
表達 代表 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
另請參閱
支援和意見反應
有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應。