Shape_added event for a page

Started by ivan, April 05, 2009, 06:50:49 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ivan

I ha ve a script that is lauched via Document_ShapeAdded event. but i only need it on one page for all the others it has to be disabled. How can i make marcos worl just for one page ?

JuneTheSecond

#1
Hi,

Simply place a line at the beginning.
If Not ActivePage.ID = X then Exit Sub
or
If Not ActivePage.Name = XXX then Exit Sub
Best Regards,

Junichi Yoda
http://june.minibird.jp/

Visio Guy

Hi bdfy,

You could also set up a ShapeAdded event for just one page. This sample code shows one way to do it:


'// ThisDocument

Dim WithEvents pg As Visio.Page

Private Sub Document_RunModeEntered(ByVal doc As IVDocument)
 
  '// Set the WithEvents Visio.Page variable when
  '// this document is opened or the VBA Run Mode/Design Mode
  '// triangle-button is toggled
  Set pg = ThisDocument.Pages(1)
 
End Sub

Private Sub pg_ShapeAdded(ByVal Shape As IVShape)
  '//...do something
End Sub

For articles, tips and free content, see the Visio Guy Website at http://www.visguy.com
Get my Visio Book! Using Microsoft Visio 2010