Author Topic: Is there a "CheckIfMasterExists solution" without raising an exception?  (Read 2845 times)

0 Members and 1 Guest are viewing this topic.

Visisthebest

  • Sr. Member
  • ****
  • Posts: 433
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

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3080
    • Paul Herber's website
Re: Is there a "CheckIfMasterExists solution" without raising an exception?
« Reply #1 on: August 02, 2021, 08:31:24 AM »
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 and applications for Visio -

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

Visisthebest

  • Sr. Member
  • ****
  • Posts: 433
Re: Is there a "CheckIfMasterExists solution" without raising an exception?
« Reply #2 on: August 02, 2021, 11:26:48 AM »
Thank you for that idea Paul that will make the code flow nice & clean again!
Visio 2021 Professional