Message 1 of 15
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi All,
I have this really basic VBA code to get quantity for each model state of the parts which is doing what I wanted to do. I was just wondering if someone has an idea to do it better way. The idea is to get the quantity of each model state of each part.
Sub QtyCount()
Dim oAsmCompDef As AssemblyComponentDefinition
Set oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition
Dim i As Integer
i = 0
Dim j As Integer
j = 0
Dim k As Integer
k = 0
Dim l As Integer
l = 0
Dim n As Integer
n = 0
'Iterate through all of the occurrences
Dim oOccurrence As ComponentOccurrence
For Each oOccurrence In oAsmCompDef.Occurrences
If oOccurrence.ActiveModelState = "Master" Then
n = n + 1
ElseIf oOccurrence.ActiveModelState = "One" Then
i = i + 1
ElseIf oOccurrence.ActiveModelState = "Two" Then
j = j + 1
ElseIf oOccurrence.ActiveModelState = "Three" Then
k = k + 1
ElseIf oOccurrence.ActiveModelState = "Four" Then
l = l + 1
End If
Next
MsgBox ("Qty for Master model State is " & n & vbNewLine & "Qty for One model State is " & i _
& vbNewLine & "Qty for Two model State is " & j & vbNewLine & "Qty for Three model State is " & k _
& vbNewLine & "Qty for Four model State is " & l)
End Sub
Best regards,
Flo
Solved! Go to Solution.