Export (0) Print
Expand All

NavigationNode Object

Represents a node in the navigational structure of a Web site.

Remarks

The NavigationNode object is a member of the NavigationNodes collection. Within the NavigationNodes collection, individual NavigationNode objects are indexed beginning with zero.

  Note
From the NavigationNode object, you can access all other navigation nodes in a Web site. The RootNavigationNode object, created by default each time you create a new Web site, provides the basis for the navigation structure, which is accessed through the Children property. The first child node of the navigation structure is usually the home page of the Web site, which can be accessed through the HomeNavigationNode property. However, the first child node of the root navigation node can be any page, and may not contain a HomeNavigationNode object at all.

You can use the NavigationNode property to return the NavigationNode object. The following example builds a list of navigation node labels for the WebFile object of the WebFiles collection.

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
            If myFile.NavigationNode is Nothing Then
                     Dont do anything
            Else
                     myLabel = myFile.NavigationNode.Label
                     If Err <> 0 Then Exit Sub
                     myNavNodeLabel = myNavNodeLabel & myLabel & vbCRLF
        Next
    End With
End Sub

The Children property returns the collection of child nodes within the navigation structure of a Web site.

Use Children(index), where index is the index number of a navigation node item, to return a single NavigationNode object. The following statement returns the file name of the first navigation node in the NavigationNodes collection.

Visual Basic for Applications
myNavNodeName _
    = ActiveWeb.RootFolder.Files(0).NavigationNode.Children(0).File.Name

The File property returns the File object that is associated with the NavigationNode object. The following statement returns True if the file is open.

Visual Basic for Applications
myNavFile = ActiveWeb.RootFolder.Files(3).NavigationNode.File.IsOpen

The Home property returns the Home object that is associated with the current navigation node and references information such as the Children, File, Label, Next, Prev, and other properties for the home page. The following statement returns the URL of the Home property for the NavigationNode object.

Visual Basic for Applications
myHomePageUrl _
    = ActiveWeb.RootFolder.Files(5).NavigationNode.Home.Url

You can return the Label property to set or return text that can be used as buttons within the navigation structure or used for text in a link bar. The following example returns the label for the home page.

Visual Basic for Applications
myLabel = ActiveWeb.RootFolder.Files(0).NavigationNode.Label

Use the Next, Parent, Prev, or Url properties to return navigation nodes that are associated with the specified property. The following example returns the URL that is associated with the previous NavigationNode object.

Visual Basic for Applications
myPrevNode = ActiveWeb.RootFolder.Files(1).NavigationNode.Prev.Url

Use the Web property to return the Web object that is associated with the current navigation node. The following example returns the Web object for the current navigation node.

Visual Basic for Applications
myNavNodeWeb = _
    ActiveWeb.RootFolder.Files(2).NavigationNode.Web.Url

Use the Move method to move a navigation node from one child node to another. The following example moves a navigation node to a child location on a sibling node in the same Web site.

Visual Basic for Applications
Private Sub MoveNavNode()
Dim myNodes As NavigationNodes
Dim myNode As NavigationNode

Set myNodes = ActiveWeb.RootNavigationNode.Children
Set myNode = myNodes(4)

myNode.Move myNodes, myNodes(2)
ActiveWeb.ApplyNavigationStructure
End Sub



Community Additions

ADD
Show:
© 2015 Microsoft