Message 1 of 2
ArrayList Compile error: Sub or Function not define
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm using Inventor 2019 and using the vba editor. My code is to try and get the child nodes of the content center hierarchy. The code works when looping through and posting a message box at each loop. Now I would like to capture the display name of each child node in a list. However, at the "Dim NodeArrayList As New ArrayList" line I get the compile error. When reviewing that call to online help, it should work. Any suggestions?
Sub RecursiveNodes()
Dim cc As ContentCenter
Set cc = ThisApplication.ContentCenter
Dim NodeArrayList As New ArrayList
' For Level1 = 1 To cc.TreeViewTopNode.ChildNodes.Count
For Level1 = 1 To 2
' MsgBox (cc.TreeViewTopNode.ChildNodes.Item(Level1).DisplayName)
NodeArrayList.Add (cc.TreeViewTopNode.ChildNodes.Item(Level1).DisplayName)
For Level2 = 1 To cc.TreeViewTopNode.ChildNodes.Item(Level1).ChildNodes.Count
' MsgBox (cc.TreeViewTopNode.ChildNodes.Item(Level1).ChildNodes.Item(Level2).DisplayName)
NodeArrayList.Add (" " & cc.TreeViewTopNode.ChildNodes.Item(Level1).ChildNodes.Item(Level2).DisplayName)
For Level3 = 1 To cc.TreeViewTopNode.ChildNodes.Item(Level1).ChildNodes.Item(Level2).ChildNodes.Count
' MsgBox (cc.TreeViewTopNode.ChildNodes.Item(Level1).ChildNodes.Item(Level2).ChildNodes.Item(Level3).DisplayName)
NodeArrayList.Add (" " & " " & cc.TreeViewTopNode.ChildNodes.Item(Level1).ChildNodes.Item(Level2).ChildNodes.Item(Level3).DisplayName)
For Level4 = 1 To cc.TreeViewTopNode.ChildNodes.Item(Level1).ChildNodes.Item(Level2).ChildNodes.Item(Level3).ChildNodes.Count
' MsgBox (cc.TreeViewTopNode.ChildNodes.Item(Level1).ChildNodes.Item(Level2).ChildNodes.Item(Level3).ChildNodes.Item(Level4).DisplayName)
NodeArrayList.Add (" " & " " & " " & cc.TreeViewTopNode.ChildNodes.Item(Level1).ChildNodes.Item(Level2).ChildNodes.Item(Level3).ChildNodes.Item(Level4).DisplayName)
Next
Next
Next
Next
'Message box to verify the hierarchy
Dim NodeArrayListVariable As String
If NodeArrayList.Count > 0 Then
For Each Counter In NodeArrayList
NodeArrayListVariable = NodeArrayListVariable & NodeArrayList(Counter) & vbNewLine
Next
Else
MsgBox ("Node Array List wasn't created")
End If
MsgBox (NodeArrayListVariable)
End Sub