Shape.Text 属性 (Visio)

返回形状的所有文本。 读/写。

语法

表达式文本

expression 一个代表 Shape 对象的变量。

返回值

String

备注

Shape 对象的 Text 属性返回的文本中,字段由转义字符 (30 (&H1E) ) 表示。 如果希望文本包含展开的字段,请获取形状的 Characters 属性,然后获取生成的 Characters 对象的 Text 属性。

如果该形状是一个组,则返回的文本取决于 IsTextEditTarget 单元格的值。

  • 如果 IsTextEditTarget 为 True则 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 支持和反馈,获取有关如何接收支持和提供反馈的指南。