Which VBA event to use for equivalent of AfterShapeDelete

J

John

Problem: Which VBA event to use for equivalent of AfterShapeDelete

Visio 2007 SP2
Windows XP SP3

Since there is no AfterShapeDelete event, I tried the ShapeChanged event for
App assuming an event would occur when I interactively deleted a shape. App
ShapeChanged was entered upon adding a shape. However, upon interactively
deleting the same shape, App ShapeChanged was not entered since my
Debug.Print "vsoApp_ShapeChanged" did not print. Did I do something wrong or
is there another event I should be using? Thanks in advance.
 
J

John

Looking at the documentation for the Application.ShapeChanged event
(http://msdn.microsoft.com/en-us/library/ms427878.aspx), it appears that only
a few things actually trigger a ShapeChanged event. This includes changing
the Name of the shape.

This seems a kludge, but changing the Name in BeforeShapeDelete triggers
ShapeChanged where you can put your code. I would hope there is a better way
than this.

Private Sub vsoApp_BeforeShapeDelete(ByVal Shape As IVShape)
Shape.Name = "dog" 'This changes the name of the shape
Debug.Print "vsoApp_BeforeShapeDelete"
End Sub

Private Sub vsoApp_ShapeChanged(ByVal Shape As IVShape)
... code
Debug.Print "vsoApp_ShapeChanged"
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top