Visio Automation Problem

Started by nilani, August 01, 2011, 05:34:00 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

nilani

Hi,

I have to run a macro program for a visio template. How to make each time a user taking a new drawing that code is running?
I have edited the master and added the macro code to it and made to run macro in the double click event of the shape. But it doesn't work when i drag and drop the master in to the drawing window?
Please help me?
Thank you.

Jumpy

Don't (only) use doubleclick event. Use OnDrop-Event, too.

nilani

Hi,
The problem is where to do the macro coding? In the template or on a shape in the drawing window?

Jumpy

If u always start your drawings from the same template, u can use the template.
In the VBA-Editor: Place the VBA code inside a modul that belongs to the project of the template.
The VBA code now is in all new drawings, based on that template.
You can call the Code
either via CALLTHIS Function in the OnDrop-Event ShapeSheet,
or with the Shape_Added Event in the ThisDocument modul of the templates VBA-Project.

The other way would be to open the stencil (that contains your mastershapes) in edit mode.
If you switch to the VBA editor, you can now see the VBA project of the stencil, too.
Now you can place your code in a new modul there.
You can call the Code via CALLTHIS Function in the OnDrop-Event ShapeSheet.

nilani

Thank you very much. By the way I found a method to accomplish my task:) Now experimenting on it. If It would make any success I'll post it for the future reference for the viewers of this forum.  :) Thanks again.

Paul Herber

Put your macro in the template.
Electronic and Electrical engineering, business and software stencils for Visio -

https://www.paulherber.co.uk/