This procedure will print all of the labels of the navigation nodes into a new Excel sheet. All children will be placed immediately below and one column to the right of their parent. It will work up to 6 generations and could easily be expanded to include more generations if needed.
The MaxGen variable will show the last generation containing any children.
Sub ShowNavigationSructure() Dim objGen1 As NavigationNode Dim objGen2 As NavigationNode Dim objGen3 As NavigationNode Dim objGen4 As NavigationNode Dim objGen5 As NavigationNode Dim objGen6 As NavigationNode Dim MaxGen As Byte Dim intCopyRow As Integer intCopyRow = 2 If Not OpenExcel Then GoTo _ errHandler1 If Not WorkbookNewNameSaveAs Then _ GoTo errHandler1 If Not SetNewWorksheetName Then _ GoTo errHandler1 Set objGen1 = Application.ActiveWeb. _ AllNavigationNodes.Item(0) objWorksheet.cells(intCopyRow, 1) = _ objGen1.Label intCopyRow = intCopyRow + 1 MaxGen = 1 For i = 0 To objGen1.Children.Count - 1 Set objGen2 = objGen1.Children.Item(i) objWorksheet.cells(intCopyRow, 2) = _ objGen2.Label intCopyRow = intCopyRow + 1 If MaxGen < 2 Then MaxGen = 2 End If For j = 0 To objGen2.Children.Count - 1 Set objGen3 = objGen2.Children.Item(j) objWorksheet.cells(intCopyRow, 3) = _ objGen3.Label intCopyRow = intCopyRow + 1 If MaxGen < 3 Then MaxGen = 3 End If For k = 0 To objGen3.Children.Count - 1 Set objGen4 = objGen3.Children.Item(k) objWorksheet.cells(intCopyRow, 4) = _ objGen4.Label Debug.Print "Gen4 " & objGen4.Label intCopyRow = intCopyRow + 1 If MaxGen < 4 Then MaxGen = 4 End If For l = 0 To objGen4.Children.Count - 1 Set objGen5 = objGen4.Children.Item(k) objWorksheet.cells(intCopyRow, 5) = _ objGen5.Label intCopyRow = intCopyRow + 1 If MaxGen < 5 Then MaxGen = 5 End If For m = 0 To objGen5.Children.Count - 1 Set objGen6 = objGen5.Children.Item(k) objWorksheet.cells(intCopyRow, 6) = _ objGen6.Label intCopyRow = intCopyRow + 1 If MaxGen < 6 Then MaxGen = 6 End If Next m Next l Next k Next j Next i x = MaxGen Exit Sub errHandler1: MsgBox "ShowNavigationStructure has failed", _ vbCritical, "Function Failure" End Sub
Sample Output:
| Gen1 | Gen2 | Gen3 | Gen4 |
|---|---|---|---|
| Glenfield 1886 - 1987 | |||
| Dedication | |||
| Acknowledgment | |||
| Glenfield 1884 - 1912 | |||
| 1890 | |||
| Charley Thompson | |||
| Tollof and Regina Thompson | |||
| Thorvel and Malinda (Johanson) Thompson | |||
| 1892 | |||
| Anders and Anna (Olson) Pierson | |||
| Peter and Thea (Thompson) Pierson | |||
| Theodore and Linda (Kirkeby) Johnson | |||
| Glenfield Diamond Jubilee | |||
All of the Children are indented one column to the right.