CellChanged event

Microsoft Visio Developer Reference

CellChanged event

       

Occurs after the value changes in a cell in a document.

Version added

4.1

Syntax

Private Sub object_CellChanged(ByVal Cell As IVCell)

object

The WithEvents object that receives the event.

Remarks

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. 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 CellChanged 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 CellChanged event.

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

Example

This class module demonstrates defining a sink class called ShapeSink that declares the object variable m_shpObj using the WithEvents keyword. It contains a procedure, InitWith, that assigns a particular Shape object, aShape, to m_shpObj. The class module also contains an event handler for the CellChanged event, which can be fired by a Shape object—in this case, the Shape object represented by aShape.

Dim WithEvents m_shpObj As Visio.Shape

Public Sub InitWith(ByVal aShape As Visio.Shape) 
    Set m_shpObj = aShape
End Sub

Private Sub m_shpObj_CellChanged(ByVal Cell As Visio.IVCell) 
    Debug.Print Cell.Shape.Name & " " & Cell.Name & " changed to =" & Cell.Formula
End Sub