Validate Method
Verifies an individual XML element or the entire document against the attached XML schema or schemas.
expression.Validate()
expression Required. An expression that returns one of the objects in the Applies To list.
Remarks
Use the Validate method with the ValidationStatus and ValidationErrorText properties to determine if an XML element is valid against the applied schema and what error text to display to the user. Use the SetValidationError method to override the schema violations with custom validation errors.
When you run the Validate method, Word populates the XMLSchemaViolations collection with the XML nodes that have validation errors.
Example
The following example checks each element and attribute in the active document and displays a message containing the elements and attributes that do not pass validation according to the schema and a description of why.
Dim objNode As XMLNode
Dim strValid As String
For Each objNode In ActiveDocument.XMLNodes
objNode.Validate
If objNode.ValidationStatus <> wdXMLValidationStatusOK Then
strValid = strValid & objNode.BaseName & vbTab & _
objNode.ValidationErrorText & vbCrLf
End If
Next
MsgBox "The following elements do not validate against " & _
"the schema." & vbCrLf & vbCrLf & strValid & vbCrLf & _
"You should fix these elements before continuing."