Running macros from a stencil

L

LeeAnn

Hi all.

I am trying to run a DocumentOpened macro and ShapeAdded macro from a
stencil. The macros worked OK in a drawing .vsd macro. I am thinking that
the macros are not firing in response to the document open and shape added
events. I have read the addadvise in the "help" but I am confused. I would
prefer not to put the code in the drawing document but in a stencil. Any
ideas?

Thanks for the help.
 
J

JuneTheSecond

I think your macro is on ThisDocument module.
The Document in the "Document_DocumentOpened" is your stencil.
Then, DocumentOpened fires when your stencil opens,
Document_MasterAdded fires when a maser added to your stencil.

For your drawing, make Document object to refer your drawing.
For example,
Private WithEvents myDoc As Visio.Document
and put "Set myDoc = ActiveDocument"
in the "Document_DocumentOpened" event,
and make new "myDoc_DocumentOpened" event.
 
L

LeeAnn

Thanks for the information. You are correct, the "Document_DocumentOpened"
and "Document_ShapeAdded" are in the ThisDocument of the stencil. I have no
vbscripts in the drawing.

Do I put the "Private WithEvents myDoc As Visio.Document" in the
ThisDocument of the stencil or the ThisDocument of the drawing?

Thanks for the help.
 
J

JuneTheSecond

Yes, ThisDocument of the stencil.
And please note that
the drawing is always opened when the stencol opened.
And then, myDoc_DocumentOpened event cannot recieve the event opened.
But myDoc_DocumentSaved can get events.
If you wish to get events that aother drawing is opened, add myApp_Docyment
event and adding "Set myApp=Application" in stencil opened event.
 

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