Visio Guy

Visio Discussions => Programming & Code => Topic started by: Visisthebest on August 02, 2021, 11:02:42 AM

Title: Is there a "CheckIfMasterExists solution" without raising an exception?
Post by: Visisthebest on August 02, 2021, 11:02:42 AM
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.
Title: Re: Is there a "CheckIfMasterExists solution" without raising an exception?
Post by: Paul Herber on August 02, 2021, 01:31:24 PM
If you don't like the exception (I have no problem with them) then just wrap it in a procedure.

Title: Re: Is there a "CheckIfMasterExists solution" without raising an exception?
Post by: Visisthebest on August 02, 2021, 04:26:48 PM
Thank you for that idea Paul that will make the code flow nice & clean again!