- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi, I've been struggling with some code recently that traverses through my design tree which I intend to have the script identify certain part numbers and run a private sub on that part number. I can get it to traverse the tree just fine and run private subs based on whether it is a part or an assembly however, prior to where it's returning part or assembly and running a sub based on that criteria, I have it set to look for specific part numbers and run a private sub based on whether or not that part number matches a few pre-determined ones. The code is as follows however it seems like it's having issues with the oOcc.name not matching the part number variable (trough) which is defined as a string.
If you were going to have VBA run a private sub based on a part number how would you do it?
' Iterate through assembly
Dim oOcc As ComponentOccurrence
For Each oOcc In Occurrences
' Print the name of the current occurrence.
'Debug.Print Space(Level * 3) & oOcc.Name
'Call appropriate part or assembly sub
If oOcc.DefinitionDocumentType = kPartDocumentObject Then
'compare part number strings
If Trough = oOcc.Name Then -->(Trough is previously defined as a global string outside of the public sub with a few other variables that get passed between various private subs)
Call TroughLoop(oOcc)
Else
Call PartParameter(oOcc)
'End If
ElseIf oOcc.DefinitionDocumentType = kAssemblyDocumentObject Then
'compare assembly part number strings
Call AssemblyParameter(oOcc)
End If
Solved! Go to Solution.