catch a template name of a shape

Started by chrisoft, June 09, 2016, 12:12:05 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

chrisoft

Dear Visio Dev,

Hope you're fine,

I am looking for a property or a function that return the name of a template related to a shape that has been just dropped ?

I have tried to find into in the vba spy editor of the active shape but did not find anything concerning the template name.

I have attached a picture of what I am looking for in case of...

Many thanks for your support

Paul Herber

That's the stencil name that you want, not the template name.
As far as I know there is no connection from a shape back to the stencil it came from.
Electronic and Electrical engineering, business and software stencils for Visio -

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

chrisoft

Dear Paul,

Yes sorry I was referring to the stencil name.

that's what I thought, many thanks for your confirmation.

Anyway, I am thinking to an alternative solution but not sure it's workable : is there a possibility to loop over the shapes that are in a stencil  ?

Paul Herber

You could but each stencil may contain a shape(s) of exactly the same name(s).
Electronic and Electrical engineering, business and software stencils for Visio -

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

chrisoft

Dear Paul,

In case of I have several shapes in several stencil but named differently, would you please be so kind to help me to find wich collection I have to call ?
what I'm thinking is something like

For each shp in ?? "stencil" (which could be activewindow.masters or smth like that)
'my treatment code
next

Many thanks for your support

Hey Ken

Chrisoft:

   A simple solution is to add a user cell to the shapesheet of each shape on your stencil, then save the stencil name there.  Then you can access it generally like this:


If MyShape.Cells("User.StencilName").Formula = """stencil""" then...


   I already do that with version numbers on my stencil's shapes so I can know when a shape needs to be upgraded.

   Hope this helps,

   - Ken


Ken V. Krawchuk
Author
No Dogs on Mars - A Starship Story
http://astarshipstory.com

wapperdude

@Ken:  nice, simple, unambiguous solution

Too bad it's not a built-in shape feature!

Wapperdude
Visio 2019 Pro

chrisoft

Dears,

Indeed it could be an alternative solution by writting the stencil name directly in the shapesheet of the master.
The thing is, in my project I have around 500 masters splittted in 19 stencils. a painfull task to do manually.

The best would be to loop over each master in each stencil for two reasons

1 - compare the name of the master with the shape dropped in order to know whether the shape is coming from the said stencil
2 - your solution : add the name of the stencil into the shapesheet

But I do not success to loop over all masters in stencil

For each master in activewindow.masters
debug.print master.name
'add name into shapesheet
Next

I am under the impression this loop returns me all masters that are in the drag & drop "buffer"...