3 4
After you add an ActiveX control to the drawing page, you can handle the various events issued by the control—for example, if you insert a command button, you can handle its Click event. You handle a control's events by writing event procedures in the Microsoft Visual Basic for Applications (VBA) project of the Microsoft Visio drawing that contains the control, just as you would handle a Visio event.
For example, the following event procedure for a command button deletes a shape in the Visio drawing when a user selects the shape's name in a listbox control and clicks the command button:
Private Sub CommandButton1_Click( ) Dim visShape As Visio.Shape If ListBox1.ListIndex >=0 Then Set visShape = _ ActivePage.Shapes(ListBox1.Text) visShape.Delete End If End Sub