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

CustomXMLSchemaCollection.Add Method (Office)

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

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.


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

expression An expression that returns a CustomXMLSchemaCollection object.


NameRequired/OptionalData TypeDescription
NamespaceURIOptionalStringContains 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.
AliasOptionalStringContains 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.
FileNameOptionalStringContains the location of the schema on a disk. If this parameter is specified, the schema is added to the collection and to to the Schema Library.
InstallForAllUsersOptionalBooleanSpecifies 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



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. 
        MsgBox (Err.Description) 
        Resume Next 
End Function 

See also


CustomXMLSchemaCollection Object

Other resources

CustomXMLSchemaCollection Object Members

© 2018 Microsoft