SubTree Property
Returns a NavigationNodes collection object that represents a collection of all the nodes in the subtree of the current navigation node. A subtree of a node is defined as all nodes which are adjacent to or attached to the parent node and appear below the parent node in the tree hierarchy.
expression.SubTree
expression Required. An expression that returns a NavigationNode object.
Example
The following example prompts the user to enter the name of a navigation node in the current Web site and returns the subtree for that particular node. If the node is found, its label property value is added to a String containing the names of all nodes in the parent node's subtree. The String stored in the variable strSubNodes is displayed to the user. If the node is not found in the Web site, a message is displayed to the user.
Sub DisplaySubTree()
'Returns the subtree of a given node
Dim objApp As FrontPage.Application
Dim objNavNode As NavigationNode
Dim objNavNodes As NavigationNodes
Dim objSubTree As NavigationNodes
Dim objSubNode As NavigationNode
Dim strAns As String 'User input
Dim blnFound As Boolean 'Boolean found flag
Dim intCount As Integer 'Integer counter
Dim strSubNodes As String 'Names of all sub nodes
blnFound = False
intCount = 0
Set objApp = FrontPage.Application
'Create a reference to the NavigationNodes collection
Set objNavNodes = objApp.ActiveWeb.AllNavigationNodes
'Prompt the user to enter the name of the node
strAns = InputBox("Enter the name of the node for which " & _
" you want to view the subtree.")
'While the node is not found and there are more nodes in the tree
Do While (Not blnFound = True) And (intCount <= objNavNodes.Count - 1)
'Compare user input with node label
If Trim(strAns) = objNavNodes.Item(intCount).Label Then
'If found, return node
Set objNavNode = objNavNodes.Item(intCount)
'Set found flag to true
blnFound = True
Else
'Otherwise increase counter, keep checking
intCount = intCount + 1
End If
Loop
If blnFound = True Then
Set objSubTree = objNavNode.SubTree
For Each objSubNode In objSubTree
'If the string is empty or has not yet been set
If strSubNodes = "" Then
strSubNodes = strSubNodes & objSubNode.Label
Else
'otherwise add next node lable to string
strSubNodes = strSubNodes & ", " & vbCr & objSubNode.Label
End If
Next objSubNode
'Display names of all nodes in subtree
MsgBox "The nodes found in the subtree of " & objNavNode.Label & " are: " _
& vbCr & vbCr & strSubNodes & "."
Else
'If not found, display message to user
MsgBox "The navigation node " & strAns & " was not found."
End If
End Sub