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 ...

Get Microsoft Visio 2010 Business Process Diagramming and Validation now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.