Community articleDuplicate function
Added by IBM contributorIBM on August 15, 2011
Rate this article 1 starsRate this article 2 starsRate this article 3 starsRate this article 4 starsRate this article 5 stars

No abstract provided.


This function makes a copy of a node. The duplicated node can be attached to any other node as either a sibling or a child, or can be stored as a separate node structure. The new node can also be assigned a new identifier with the theIdentifier parameter. All of the properties of the original node are duplicated, including any children and any namespace settings.
Note: If you duplicate a node that is not in the XFDL namespace, the namespace is copied as part of the duplicated node, but is not set globally.


   Function Duplicate(
      baseNode As IFormNodeP, 
      where As Long, 
      theIdentifier As String
      ) As IFormNodeP


Table 1. Function parameters
baseNodeIFormNodePThe formNodeP to attach the new copy to.
where LongA constant that describes the location in relation to the supplied baseNode in which the new node should be placed. Can be one of:
UFL_APPEND_CHILD — adds the new node as the last child of the baseNode.
UFL_AFTER_SIBLING — adds the new node as a sibling of the baseNode, placing it immediately after that node in the form structure.
UFL_BEFORE_SIBLING — adds the new node as a sibling of the baseNode, placing it immediately before that node in the form structure.
UFL_ORPHAN — copies the node but does not insert it into the form structure.
theIdentifierStringThe new id attribute for this node. If null, the id attribute of the original node is used.


The duplicate node or throws an exception if an error occurs.


The following function duplicates a page in the form, including all of the items on the page. First, the function uses DereferenceEx to locate the PAGE2 node and then the PAGE3 node. Next, the function uses Duplicate to create a copy of the PAGE2 node and place it after the PAGE3 node.
   Sub DuplicatePage(Form)
      Dim CopyNode, DestinationNode  ' objects
      Set CopyNode = Form
      Set DestinationNode = Form
      ' Locate the page 2 node.  This is the node that will be copied.
      Set CopyNode = CopyNode.DereferenceEx(vbNullString, "PAGE2", 0, _
         UFL_PAGE_REFERENCE, Nothing)
      ' Locate the last page node.  The copy will be inserted to the right
      ' of this node in the form structure.  In other words, the copy will
      ' become the last page.
      Set DestinationNode = DestinationNode.DereferenceEx(vbNullString, _
         "PAGE3", 0, UFL_PAGE_REFERENCE, Nothing)
      ' Duplicate the page 2 node, inserting it after the page 3 node. The
      ' new page will be named PAGE4.
      Set CopyNode = CopyNode.Duplicate(DestinationNode, UFL_AFTER_SIBLING,_
   End Sub

Parent topic:
FormNodeP functions