Share via


NavigationNodes Collection

SharePoint Designer Developer Reference

A collection of NavigationNode objects within the navigational structure of a Web site.

Remarks

Each NavigationNode object represents a pointer to a page on a Web site. The NavigationNode object is a member of the NavigationNodes collection.

Use the NavigationNode property to return the NavigationNode object for a WebFile object. For more information on returning the collection of child nodes within the navigational structure of a Web site, see the Children property. The following example builds a list of the labels that are associated with each NavigationNode object in the NavigationNodes collection. The procedure exits when it reaches the end of the navigational structure.

Visual Basic for Applications
Private Sub GetNavigationNode()
    Dim myWeb As Web
    Dim myWebFiles As WebFiles
    Dim myWebFile As WebFile
    Dim myNavNodeLabel As String
    Dim myLabel As String
    On Error Resume Next
    Set myWeb = ActiveWeb
    Set myFiles = myWeb.RootFolder.Files
    With myFiles
        For Each myFile In myFiles
            myLabel = myFile.NavigationNode.Label
            If Err <> 0 Then Exit Sub
            myNavNodeLabel = myNavNodeLabel & myLabel & vbCRLF
        Next
    End With
End Sub

Use Children(index), where index is the index number of an item in the collection of child nodes, to return a single NavigationNode object. The following example returns the first NavigationNode object in the collection—which is the home page.

Visual Basic for Applications
Set myNavNodeOne = ActiveWeb.RootNavigationNode.Children(0)

Use the Add method to add a NavigationNode object to the NavigationNodes collection. The following example adds a node to the rightmost position in the current navigational structure.

Visual Basic for Applications
Private Sub AddNewNavNode()
    Dim myWeb As Web
    Dim myNewNavNode As NavigationNode
    Dim myNavChildren As NavigationNodes
    Set myWeb = ActiveWeb
    Set myNavChildren = _
        myWeb.rootfolder.Files(1).NavigationNode.Children
    myNewNavNode = _
        myNavChildren.Add("C:\My Webs\Sale.htm", "Sale", NodeLocationAsRightMostChild)
    myWeb.ApplyNavigationStructure
End Sub

Note

After you finish modifying your navigational structure, you must apply the changes using the ApplyNavigationStructure method before the navigational structure is updated in Office SharePoint Designer.

See Also