Text Property [Visio 2003 SDK Documentation]

As it applies to the Characters object.

Returns the range of text represented by a Characters object, which may be a subset of the shape's text depending on the values of the Characters object's Begin and End properties.

strRet = object**.Text**

object**.Text** = stringExpression

strRet     Variant. The text of the Characters object returned in a Variant of type String.

object     Required. An expression that returns the Characters object that owns the text.

stringExpression     Required Variant. The text of the Characters object in a Variant of type String.

Version added

2.0

Remarks

The text for a Characters object is returned in a Variant of type String, as opposed to in a String. This is typically transparent if you are using Microsoft Visual Basic.

In the text returned by a Characters object, fields are expanded to the number of characters that are visible in the drawing window. For example, if a shape's text contains a field that displays the file name of a drawing, the Text property of a Characters object returns the expanded file name (provided the Begin and End properties were not altered).

If a Characters object represents the text of a shape that is a group, it will always return the text of the group.

Objects from other applications and guides don't have a Text property.

As it applies to the Shape object.

Returns all of the shape's text.

strRet = object**.Text**

object**.Text** = stringExpression

strRet     String. The text of the Shape object returned as a string.

object     Required. An expression that returns a Shape object.

stringExpression     Required String. New text for the Shape object.

Version added

2.0

Remarks

In the text returned by the Text property of a Shape object, fields are represented by an escape character (30 (&H1E)) For example, if a Shape object's text contains a field that displays the file name of a drawing, the Shape object's Text property returns an escape character where that field is inserted into the text. If you want the text to contain the expanded field, get the shape's Characters property, and then get the Text property of the resulting Characters object.

If the shape is a group, the text returned is dependent on the value of the IsTextEditTarget cell.

  • If IsTextEditTarget is TRUE, the Text property of the Shape object returns the text of the group.
  • If IsTextEditTarget is FALSE, the Text property of the Shape object returns the text of the shape in the group at the top of the stacking order.

Objects from other applications and guides do not have a Text property.

Example

As it applies to the Characters object.

This Microsoft Visual Basic for Applications (VBA) macro shows how to get the Text property of a Characters object.

Public Sub CharactersText_Example() 

    Dim vsoOval As Visio.Shape 
    Dim vsoCharacters As Visio.Characters 

    'Create a shape and add text.
    Set vsoOval = ActivePage.DrawOval(2, 5, 5, 7) 
    vsoOval.Text = "Oval Shape" 

    'Get a Characters object from the shape.
    Set vsoCharacters = vsoOval.Characters 

    'Get the text from the Characters object.
    Debug.Print vsoCharacters.Text 

End Sub

As it applies to the Shape object.

This Microsoft Visual Basic for Applications (VBA) macro shows how to get the Text property of a shape.

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

Applies to | Characters object | Shape object

See Also | Characters object | Characters property | Text property