Is there a "CheckIfMasterExists solution" without raising an exception?

Started by Visisthebest, August 02, 2021, 11:02:42 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Visisthebest

For checking whether a cell exists, Visio has a very elegant solution with the Exists methods for cells.

Unfortunately for checking whether a master exists in a stencil, I cannot find an elegant solution. (I found an extensive topic on how to check if a master exists on this forum but no elegant solution).

In a VB.NET add-in I can of course use Masters.ItemU("Universal name of master") by putting it in a Try...Catch block to check if the master exists, by either raising an exception or not, but this is ugly programming.

If no elegant solution exists, I would hope Microsoft adds a MasterExists method to Visio 2023, but maybe I am overlooking an elegant solution that exists today.
Visio 2021 Professional

Paul Herber

If you don't like the exception (I have no problem with them) then just wrap it in a procedure.

Electronic and Electrical engineering, business and software stencils for Visio -

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

Visisthebest

Thank you for that idea Paul that will make the code flow nice & clean again!
Visio 2021 Professional