Table of contents
Collapse the table of content
Expand the table of content

ValidationRules.Add Method (Visio)

office 365 dev account|Last Updated: 6/12/2017
1 Contributor

Adds a new, empty ValidationRule object to the ValidationRules collection of the document.


expression . Add( NameU )

expression A variable that represents a ValidationRules object.


NameRequired/OptionalData TypeDescription
NameURequiredStringThe universal name to assign to the new validation rule.

Return Value



If the NameU parameter is not a valid string, Visio returns an Invalid Parameter error.

The default property values of the new validation rule are as follows: Category = [empty]; Description = "Unknown"; FilterExpression = [empty]; Ignored = False ; TargetType = visRuleTargetShape ; TestExpression = [empty].


The following sample code is based on code provided by: David Parker

The following Visual Basic for Applications (VBA) example shows how to use the Add method to add a new validation rule named "UngluedConnector" to an existing validation rule set named "Fault Tree Analysis" in the active document.

Public Sub Add_Example()

    Dim vsoValidationRule As Visio.ValidationRule
    Dim vsoValidationRuleSet As Visio.ValidationRuleSet
    Dim strValidationRuleSetNameU As String
    Dim strValidationRuleNameU As String

    strValidationRuleSetNameU = "Fault Tree Analysis"
    strValidationRuleNameU = "UngluedConnector"

    Set vsoValidationRuleSet = ActiveDocument.Validation.RuleSets(strValidationRuleSetNameU)
    Set vsoValidationRule = vsoValidationRuleSet.Rules.Add(strValidationRuleNameU)

End Sub
© 2017 Microsoft