2

I am trying to run a macro when I double click on Visio shapes.

I want to pass the shape object to the VBA macro so that I could do something in the macro depending on the id of the Shape object.

Is it possible to pass the parameter to VBA macro. If yes, please let me know how?

Thanks.

2 Answers 2

1

You can put your macro as the EventDblClick event on the shapes you want to watch. To do this you would use the CallThis function (http://msdn.microsoft.com/en-us/library/aa212649(office.11).aspx) to have your macro called every time a shape is double-clicked.

This would require though, that you modify the shapesheet for every shape you want to watch. If you're providing the master(s) for the shapes you want to watch it shouldn't be a big deal, but otherwise you'd have to write code that will add the event to every shape you want to watch (though you could use the Document_ShapeAdded event on a document to add your event to the shapesheet whenever a shape is added)

1

When you click on an object, the Selection changes. You can use the Selection object in your macro to refer to the currently selected object.

I'm not sure if a macro can be run on double click, but my VBA experience does not come from Visio. As bit of googling turns up that this somehow seems to be possible. If you put it as a Button on a CommandBar, with a little more effort even in the context menu, you would be restricted to a Sub procedure without parameters in any case.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.