會傳回圖形的所有文字。 讀取/寫入。
語法
表情。簡訊
expression 一個用於表示 Shape 物件的變數。
傳回值
字串
註解
在 Shape 物件的 Text 屬性回傳的文字中,欄位以 30 (&H1E (轉脫字元表示) ) 例如,若 Shape 物件的文字包含顯示繪圖檔案名稱的欄位,Shape 物件的 Text 屬性會回傳一個跳脫字元,該欄位會插入文字中。 如果你想讓文字包含展開欄位,先取得形狀的 Characters 屬性,然後取得產生的 Characters 物件的 Text 屬性。
如果圖形是群組,則傳回的文字是根據 IsTextEditTarget 儲存格的值而定。
如果 IsTextEditTarget 為真,Shape 物件的 Text 屬性會回傳該群組的文字。
如果 IsTextEditTarget 為 False,Shape 物件的 Text 屬性會回傳堆疊順序頂端該形狀的文字。
來自其他應用程式的物件及輔助線都沒有 Text 屬性。
如果 Visual Studio 解決方案包括 Microsoft.Office.Interop.Visio 參照,這個屬性會對應至下列類型:
- Microsoft.Office.Interop.Visio.IVShape.Text
範例
下列的 Microsoft Visual Basic for Applications (VBA) 巨集會示範如何取得圖形的 Text 屬性。
Public Sub ShapeText_Example()
Dim vsoRectangle As Visio.Shape
Dim vsoOval As Visio.Shape
Dim vsoShapeFromCell As Visio.Shape
Dim vsoShapeFromCharacters As Visio.Shape
Dim vsoCell As Visio.Cell
Dim vsoCharacters As Visio.Characters
'Create 2 different shapes and add different text to each shape.
Set vsoRectangle = ActivePage.DrawRectangle(2, 3, 5, 4)
Set vsoOval = ActivePage.DrawOval(2, 5, 5, 7)
vsoRectangle.Text = "Rectangle Shape"
vsoOval.Text = "Oval Shape"
'Get a Cell object from the first shape.
Set vsoCell = vsoRectangle.Cells("Width")
'Get a Characters object from the second shape.
Set vsoCharacters = vsoOval.Characters
'Use the Shape property to get the Shape object.
Set vsoShapeFromCell = vsoCell.Shape
Set vsoShapeFromCharacters = vsoCharacters.Shape
'Use each shape's text to verify the proper Shape
'object was returned.
Debug.Print vsoShapeFromCell.Text
Debug.Print vsoShapeFromCharacters.Text
End Sub
支援和意見反應
有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應。