Shape.Characters Property

Visio Automation Reference

Returns a Characters object that represents the text of a shape. Read-only.

Version Information
 Version Added:  Visio 3.0

Syntax

expression.Characters

expression   A variable that represents a Shape object.

Return Value
Characters

Example

The following Microsoft Visual Basic for Applications (VBA) macro shows how to use the Characters property of a shape to get a Characters object. Once a Characters object has been retrieved, the example uses the Shape property of the Characters object to get the shape that contains the characters and demonstrates that the containing shape has been retrieved by printing its text in the Immediate window.

Visual Basic for Applications
  
Public Sub Characters_Example()
 
    Dim vsoOval As Visio.Shape 
    Dim vsoShapeFromCharacters As Visio.Shape 
    Dim vsoCharacters As Visio.Characters 
'Create a shape and add text to it.
Set vsoOval = ActivePage.DrawOval(2, 5, 5, 7) 
vsoOval.Text = "Rectangular Shape" 

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

'Set the Begin and End properties so that we can
'replace the word "Rectangular" with "Oval"
vsoCharacters.Begin = 0
vsoCharacters.End = 11
vsoCharacters.Text = "Oval"

'Use the Shape property of the Characters object
'to get the Shape object.
Set vsoShapeFromCharacters = vsoCharacters.Shape 

'Print the shape's text to verify that the proper Shape
'object was returned. 
Debug.Print vsoShapeFromCharacters.Text

End Sub

See Also