How to activate a loaded Visio Stencil programmatically?

Started by AmitJain23, January 09, 2024, 05:54:29 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

AmitJain23

Hello All,
I have 2 customized Stencil's In Visio - Stencil 1 and Stencil 2. Based on its loading Visio makes Stencil 2 as default. I want to make Stencil 1 as default Stencil when we open Visio. I cannot do changes into the Stencil loading. So is there any inbuilt API to make Stencil 1 as default.

Yacine

Just guessing, because you are probably mixing up the names.
You have a stencil with two masters (or more) and have some code where you probably link data to shapes to drop on the drawing and when automatically linked, Visio will take the default master.

I don't know how to change the default master, but I know that you can define which master is dropped on the drawing.
Basically you would drop the desired master - using its name and storing its handle and only then you would link it to data.
Something like
shp = activepage.drop(myMaster, x,y)
shp link to so and so.
Yacine

wapperdude

Why not create a template file?  It could have your desired shape preloaded and all desired drawing characteristics defined, and avoid the stencil altogether.  The User would use this file to get started.
Visio 2019 Pro

AmitJain23

Hello Yacine,

Yes, I have 2 stencil's with multiple SHAPES. But I want to know regarding the stencil not regarding Dropping the shapes into the Drawing.
When you open the Visio you can see in the left drawer a selected Stencil. The selection is based on the which Loads at the Last.
So I just want to know if it is possible to make the Desired Stencil Selected on opening of the Visio

AmitJain23

Quote from: wapperdude on January 09, 2024, 04:58:56 PM
Why not create a template file?  It could have your desired shape preloaded and all desired drawing characteristics defined, and avoid the stencil altogether.  The User would use this file to get started.

I cannot create the template because it is up to the user what they want to do with all the shapes we have it in the Stencil.. there is no Default Template for it. That is why we are providing the stencil which user can use to drag and drop the required shapes and create a Flow.

Yacine

Basically, you want to enhance the visibility of the stencil for better user experience. I haven't played with that idea yet.

Not sure if actually feasible, but you may want to play with the properties of the window of that stencil. Bring to front or even make it floating?
Here are some links:
- https://learn.microsoft.com/en-us/office/vba/api/visio.viswindowstates
- https://learn.microsoft.com/en-us/office/vba/api/visio.viswintypes
Yacine

Yacine

Quote from: AmitJain23 on January 10, 2024, 05:34:23 AM
I cannot create the template because it is up to the user what they want to do with all the shapes we have it in the Stencil..

A silly thought. You expect already your user to be able to open your stencil. There wouldn't then be a need to bring it forward or to set it as standard. Isn't it?
The function you request would make more sense in a template context, where a lot of stencils would be open and you want to point the right one to the user.
If the user opens your stencil by himself anyway, there is no added value from your extra function.
Yacine