CustomXMLSchemaCollection.Add method (Office)

Allows you to add one or more schemas to a schema collection that can then be added to a stream in the data store and to the Schema Library.

Syntax

expression.Add (NamespaceURI, Alias, FileName, InstallForAllUsers)

expression An expression that returns a CustomXMLSchemaCollection object.

Parameters

Name Required/Optional Data type Description
NamespaceURI Optional String Contains the namespace of the schema to be added to the collection. If the schema already exists in the Schema Library, the method will retrieve it from there.
Alias Optional String Contains the alias of the schema to be added to the collection. If the alias already exists in the Schema Library, the method can find it using this argument.
FileName Optional String Contains the location of the schema on a disk. If this parameter is specified, the schema is added to the collection and to the Schema Library.
InstallForAllUsers Optional Boolean Specifies whether, in the case where the method is adding the schema to the Schema Library, the Schema Library keys should be written to the registry (HKey_Local_Machine for all users or HKey_Current_User for just the current user). The parameter defaults to False and writes to HKey_Current_User.

Return value

CustomXMLSchema

Example

The following example adds a schema to the schema collection, selects a single node from it, and then returns the node to the calling procedure.

 Function AddSchema() 
    On Error GoTo Err 
 
    Dim objCustomXMLSchemaCollection As CustomXMLSchemaCollection 
    Dim cxp1 As CustomXMLSchema 
    Dim cxn As CustomXMLNode 
 
    ' Adds a schema to the collection.

    cxp1 = objCustomXMLSchemaCollection.Add("urn:invoice:namespace", "coreDefinitions", "wdCore.xsd", True) 
 
 ... 
 
    Set cxn = cxp4.SelectSingleNode("//*[@quantity < 4]") 
 
    AddSchema = cxn 
      
    Exit Function 
                 
 ' Exception handling. Show the message and resume. 
 Err: 
        MsgBox (Err.Description) 
        Resume Next 
 End Function 

See also

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.