Sometimes you want to get the top level document element (NotesDOMDocumentNode) of a NotesDOMNode. Here is a small function to do that. Public Function getDocumentElementOf(node As NotesDOMNode) As NotesDOMDocumentNode Dim docNode As NotesDOMDocumentNode Dim currentNode As NotesDOMNode Set currentNode = getRootNodeOf(node) Do While Not currentNode.isNull If currentNode.NodeType = DOMNODETYPE_DOCUMENT_NODE Then Set docNode = node Exit Do End If If currentNode.FirstChild.IsNull Then Set currentNode = currentNode.nextSibling Else Set currentNode = currentNode.firstChild End If Loop Set getDocumentElementOf = docNode Exit Function End Function
Use it like this (more extensive examples in the future maybe?):
Dim node As NotesDOMDocumentNode Set node = getDocumentElementOf(anotherNode)