Is there a good way to get a Master in to the document stencil without drop

Started by Visisthebest, October 04, 2021, 08:25:35 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Visisthebest

Is there a good way to get a master reliably into the document stencil without dropping a shape on to the page?

This just eliminates the unnecessary dropping then removing. The important thing is that the Master stays in the document stencil and there is not the possibility that a round of 'cleaning up' of the Visio document removes the master.

Maybe there is a setting where I can lock masters in place in the document stencil, even if there is no instance of the master on the page yet.

Or is dropping often-used shapes in to a hidden layer (so there is a shape instance and the Master cannot be 'cleaned up') a better way to go? Certainly not the most elegant solution but it would work. (or can masters actually be cleaned up if there is ONLY one shape instance on a page in the document?).

Thank you for sharing your insights & experience!
Visio 2021 Professional

Surrogate

You can drag master-shape from vss(x)-document to Document stencil!

Visisthebest

Thank you I need to do it with code, will see what Visio generates when I do that!
Visio 2021 Professional

Visisthebest

Ok I get some really easy code from the macro recorder so that will be very simple to do in code Surrogate thank you!

Application.Documents.Item("Visio document test file.vsdx").Masters.Drop Application.Documents.Item("BASIC_M.vssx").Masters.ItemU("Can"), 0#, 0#

The next question is, should I worry that is could be 'cleaned up' by Visio removing unused Masters at some point? Can I lock masters in to the Document Stencil just like I can protect shapes from delete on the page? (this also makes it harder for users to remove shapes).
Visio 2021 Professional

Surrogate

Quote from: Visisthebest on October 04, 2021, 08:52:59 AM
Thank you I need to do it with code, will see what Visio generates when I do that!
This code worksActiveDocument.Masters.Drop Documents.Item("Basic Shapes.vss").Masters.ItemU("Circle"), 0#, 0#

Visisthebest

Visio 2021 Professional

Surrogate

Quote from: Visisthebest on October 04, 2021, 08:59:36 AMThe next question is, should I worry that is could be 'cleaned up' by Visio removing unused Masters at some point?
1. You can make master as hidden in document stencil
ActiveDocument.Masters.ItemU("Can").Hidden = True It can prevent deletion from user!
2. You can create background page, and make it invisible. Drop there all masters which you need protect from purge.
    Dim vsoPage1 As Visio.Page
    Set vsoPage1 = ActiveDocument.Pages.Add
    vsoPage1.Name = "Background-4"
    vsoPage1.Background = True
    vsoPage1.Drop Application.Documents.Item("BASIC_M.vssx").Masters.ItemU("Square"), 2.362205, 5.846457
    vsoPage1.PageSheet.Cells("UIVisibility").FormulaU = 1


Visisthebest

Super Surrogate thank you, even better to use a background page rather than a layer, as I don't use the background page functionality ever!
Visio 2021 Professional

Surrogate

Quote from: Visisthebest on October 04, 2021, 09:24:20 AM
Super Surrogate thank you, even better to use a background page rather than a layer
if we talk about not advanced user, he It can accidentally detect a layer, unlock it and delete the shapes it contains. it can also, through the user interface, delete all pages in the document, including the one containing the layer storing the important wizard.
using the user interface it is not easy to get to the hidden backgroundpage  ;D

Visisthebest

Yes the background page is a much better option, and just to be sure I will lock the shapes for delete as well.
Visio 2021 Professional

Surrogate


Visisthebest

Did not know about that option as well, and I see you can protect Master shapes at this level too!

Thank you will explore this option as well.
Visio 2021 Professional