IT tutorials
 
Office
 

Microsoft Visio 2010 : The ValidationRuleSets collection

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Product Key Free : Microsoft Office 2019 – Serial Number
10/20/2011 4:31:28 PM
Validation Rules are grouped within ValidationRuleSets. The UI provides the ability to import a rule set from another open Visio document, but the programmer can use the Add(NameU as String) or AddCopy(RuleSet as ValidationRuleSet[, NameU]) methods to create a new one.

You can retrieve a rule set by its index position in the collection, using ValidationRuleSets.Item(index), or by its ID using ValidationRuleSets.ItemFromID(ID). Once you have retrieved a rule set, you can read its Name (which can be edited to be a localized version), NameU, Description (which is displayed as the tooltip in the UI), or check if the RuleSets is enabled for validation.

The RuleSetFlags value determines if the rule set is visible in the Rules to Check drop-down in the UI.

The default value is 0 (VisRuleSetFlags.visRuleSetDefault), but you could change it to 1 (VisRuleSetFlags.visRuleSetHidden) if you do not want it to appear in the Rules to Check menu.

The following macro, EnumerateRuleSets, displays a list of the rule sets in the active document:

Public Sub EnumerateRuleSets()
Dim doc As Visio.Document
Dim ruleSet As Visio.ValidationRuleSet
Set doc = Visio.ActiveDocument
Debug.Print "EnumerateRuleSets : Count = _
" & doc.Validation.RuleSets.Count
Debug.Print , "ID", "Enabled", "RuleSetFlags", _
"Name", "Description"
For Each ruleSet In doc.Validation.RuleSets
With ruleSet
Debug.Print , .ID, .Enabled, ._
RuleSetFlags, .NameU, , .Description
End With
Next
End Sub

This will produce an output similar to the following:

EnumerateRuleSets : Count = 2
ID Enabled RuleSetFlags Name Description
1 True 0 Flowchart Verify that Flowchart shapes are connected properly.
2 True 0 bVisual Sample RuleSet

How do I add or update a rule set?

Well, you can always copy a rule set from another document in the UI, but you can also create a new one in code, or update an existing one. This can be done as follows:

Public Sub AddOrUpdateRuleSet()
Dim ruleSet As Visio.ValidationRuleSet
Dim ruleSetNameU As String
ruleSetNameU = "bVisual"
'Check if the rule set exists already
Set ruleSet = _
getRuleSet(Visio.ActiveDocument, ruleSetNameU)
If ruleSet Is Nothing Then
'Create the new rule set
Set ruleSet = Visio.ActiveDocument.Validation.RuleSets.Add(ruleSetNameU)
End If
ruleSet.Name = "Be Visual"
ruleSet.Description = "Example Rule Set"
ruleSet.Enabled = True
ruleSet.RuleSetFlags = visRuleSetDefault
End Sub
ValidationRuleSets collectionruleset, updatingPrivate Function getRuleSet(ByVal doc As Visio.Document, _
ByVal nameU As String) As Visio.ValidationRuleSet
Dim retVal As Visio.ValidationRuleSet
Dim ruleSet As Visio.ValidationRuleSet
Set retVal = Nothing
For Each ruleSet In doc.Validation.RuleSets
If UCase(ruleSet.nameU) = UCase(nameU) Then
Set retVal = ruleSet
Exit For
End If
Next
Set getRuleSet = retVal
End Function


Notice how the tooltip and displayed name are updated in the UI:

Of course, you can also delete a rule set which is done as follows:

Public Sub DeleteRuleSet()
Dim ruleSetNameU As String
ruleSetNameU = "bVisual"
'Check if the rule set exists already
If Not getRuleSet(Visio.ActiveDocument, ruleSetNameU) Is Nothing Then
'Delete the rule set
Visio.ActiveDocument.Validation.RuleSets(ruleSetNameU).Delete
End If
End Sub

You can use the NameU or Index of a rule set to retrieve it from the Validation.RuleSets collection.
 
Others
 
- Microsoft PowerPoint 2010 : Showing Multiple Presentations
- Microsoft PowerPoint 2010 : Showing a Presentation with the PowerPoint Viewer & Customizing the PowerPoint Viewer
- Microsoft Excel 2010 : Checking Compatibility & Checking Accessibility
- Microsoft Excel 2010 : Saving a Workbook with Different Formats
- Microsoft Outlook 2010 : Working in the Mail Module (part 3) - Message Reading Windows
- Microsoft Outlook 2010 : Working in the Mail Module (part 2) - Message Composition Windows
- Microsoft Outlook 2010 : Working in the Mail Module (part 1)
- Microsoft OneOnte 2010 : OneNote Mobile on Windows Phone 7 (part 3)
- Microsoft OneOnte 2010 : OneNote Mobile on Windows Phone 7 (part 2)
- Microsoft OneOnte 2010 : OneNote Mobile on Windows Phone 7 (part 1)
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
Technology FAQ
- Is possible to just to use a wireless router to extend wireless access to wireless access points?
- Ruby - Insert Struct to MySql
- how to find my Symantec pcAnywhere serial number
- About direct X / Open GL issue
- How to determine eclipse version?
- What SAN cert Exchange 2010 for UM, OA?
- How do I populate a SQL Express table from Excel file?
- code for express check out with Paypal.
- Problem with Templated User Control
- ShellExecute SW_HIDE
programming4us programming4us