TextChanged event

Microsoft Visio Developer Reference

TextChanged event

   Example   

Occurs after the text of a shape is changed in a document.

Version added

4.1

Syntax

Private Sub object_TextChanged(ByVal Shape As IVShape)

object

The WithEvents object that receives the event.

Remarks

The TextChanged event is fired when the raw text of a shape changes, such as when the characters Visio stores for the shape change. If a shape's characters change because a user is typing, the TextChanged event does not fire until the text editing session terminates.

When a field is added to or removed from a shape's text, its raw text changes; hence, a TextChanged event fires. However, no TextChanged event fires when the text in a field changes. For example, a shape has a text field showing its width. A TextChanged event does not fire when the shape's width changes because the raw text stored for the shape hasn't changed, even though the apparent (expanded) text of the shape does change. Use the CellChanged event for one of the cells in the Text Fields section to detect when the text in a text field changes.

To access a shape's raw text, use the Text property. To access the text of a shape in which text fields have been expanded, use the Characters.Text property. You can determine the location and properties of text fields in a shape's text using the Shape.Characters object.

In Visio 5.0 and earlier versions, the raw characters reported by the Text property for a field included four characters, the first being the Escape character. Starting with Visio 2000, only a single Escape character is present in the raw text stream.

If you're using Microsoft Visual Basic or Visual Basic for Applications (VBA), the syntax in this topic describes a common, efficient way to handle events.

If you want to create your own Event objects, use the Add or AddAdvise method. To create an Event object that runs an add-on, use the Add method as it applies to the EventList collection. To create an Event object that receives notification, use the AddAdvise method. To find an event code for the event you want to create, see Event codes.

Note The TextChanged event is included in the event set of all the objects in the Applies to list. For those objects you can use VBA Dim WithEvents variables to sink the TextChanged event.

For performance considerations, the Document object's event set does not include the TextChanged event. To sink the TextChanged event from a Document object (and the ThisDocument object in a VBA project), you must use the AddAdvise method.