Help!!! How can I find the current stencil

Y

Yangyong

Hi! I have a Visio Automation Project in which I opened a bunch of stencils
and do some work.

The question is: How can I find which stencil is currently opened?

Thanks.
 
J

John Blight

What's the context?

If you mean through the user-interface, you can right-click on the title bar
of the stencil > Save As..., and the 'Save As' dialog should open at the
location in which the stencil is saved with the file name already populated.
This can be useful if you have several stencils with the same file name, but
stored in different folders, and you need to know which you have open.

Or do mean identifying the stencil through code?
 
N

nbelyh

Hi! I have a Visio Automation Project in which I opened a bunch of stencils
and do some work.

The question is: How can I find which stencil is currently opened?

Thanks.

If you mean though code,
then you can enumerate open "child" windows for your drawing window,
and find documents that are associated with them.

For Each child In ActiveWindow.Windows
If (child.Type = visDockedStencilBuiltIn) Then
Debug.Print child.Document.Name
End If
Next
 
Y

Yangyong

Thanks for the reply. But that's not what I want. I think I didn't make my
point very clear. Let me rephrase my question here:

When I drag and drop a shape to the drawing surface, I need to
programmatically determine which stencil this shape comes from. In the
ShapeAdded event, we can get Visio.Shape. From Shape, we can get it's Master.
If this Master is unique in all the documents, we can go through all the
stencils and find which stencil this master belongs to. However, in my case,
same master could exist in different stencils.
So, I need a way to determine which stencil is currently used.
 
D

David Parker

There is no specific property for the originating stencil, but you may be
best advised to listen to the MasterAdded event
During that event, the Master object will be given a unique name for the
document you are dropping into, but the BaseID will be same as the Master in
the originating stencil. Therefore, you can iterate through the open
stencils to get the Master with that BaseID.
As soon as the MasterAdded event is over, the new Master will have a new
BaseID, so it will be too late to get the originating stencil, so consider
updating the local Master, or SolutionXML, with the the originating stencil
name, or whatever you want.
 

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