Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
tonythm
in reply to: ckeveryga

Hi @ckeveryga 

 

I have another way, you can refer. I use excel VBA to run with Inventor. I check QTY follow part number, before that i has QTY in excel, after that i place part in assy and check QTY them in BOM Inventor with excel.

If you more learn, please let me know.

Sub CheckQTY()
    Dim oWkbk As Workbook
    Set oWkbk = ThisWorkbook
    Dim oSheet As Worksheet
    Set oSheet = oWkbk.ActiveSheet
    Dim oInv As Inventor.Application
    Set oInv = GetObject(, "Inventor.Application")
    Dim oDoc As Document
    Set oDoc = oInv.ActiveDocument
    ' Set a reference to the assembly document.
    ' This assumes an assembly document is active.
    Dim oAssy As AssemblyDocument
    Set oAssy = oInv.ActiveDocument
    Dim sParamRange As String
        sParamRange = "A44:A200"
    ' Set a reference to the BOM
    Dim oBOM As BOM
    Set oBOM = oDoc.ComponentDefinition.BOM
    oBOM.StructuredViewEnabled = True
    oBOM.StructuredViewFirstLevelOnly = True ' Display First level
    oBOM.StructuredViewMinimumDigits = 3
    Dim oBOMView As BOMView
    Set oBOMView = oBOM.BOMViews.Item("Structured")
    Dim i As Integer
    For i = 1 To oBOMView.BOMRows.Count
        Dim oRow As BOMRow
        Set oRow = oBOMView.BOMRows.Item(i)
        Dim oCompDef As ComponentDefinition
        Set oCompDef = oRow.ComponentDefinitions.Item(1)
        Dim oPartNumProperty As Property
        Set oPartNumProperty = oCompDef.Document.PropertySets.Item("Design Tracking Properties").Item("Part Number")
        
        Dim oCell As Range
        For Each oCell In oSheet.Range(sParamRange)
            'If oCell.Value = oPartNumProperty.Value Then
            'oRow.ItemNumber = oCell.Offset(0, 1).Value
            'End If
            If oCell.Value = oPartNumProperty.Value Then
                If oCell.Offset(0, 2).Value = oRow.ItemQuantity Then
                oCell.Offset(0, 2).Interior.Color = RGB(0, 176, 240)
                Else
                oCell.Offset(0, 2).Interior.Color = RGB(255, 0, 0)
                End If
            End If
        Next oCell
    Next
    Range("A40").Select
    MsgBox ("Done!")
    oWkbk.Save
End Sub