Custom validation rules in code
Previously in Chapter 4, you learnt that you can add custom validation rules in code. You would need to do this if the validation rule is too complex to phrase as Filter and Test Expressions. For example, you might want to ensure that there are no cycles (paths which return back to where they start from).
You could add code into a Visio add-in, but I will demonstrate how you can put some custom code into the drawing document as VBA because this will be in the document along with any rule set that you may have written using Filter Expression and Test Expression.
First, you need to listen for the RuleSetValidated event of the document, which can be added easily to the ThisDocument class in the VBA project. I have used ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access