Handling a Control s Events

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.

To write an event procedure for a control

  1. In the Visual Basic Editor Code window for ThisDocument, select the control from the Object box.
  2. Select the event you want to handle from the Procedure box.
  3. Fill in the event procedure in the Code window.

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 


Developing Microsoft Visio Solutions 2001
Developing Microsoft Visio Solutions (Pro-Documentation)
ISBN: 0735613532
EAN: 2147483647
Year: 2004
Pages: 180

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net