It's not physically resident in every ipt file, but it resident in every iam file.
Plus, if i use the straight export to bom sample, the entire thing exports.with all the columns present in the top level iam file.
I have modifited the above to kick out the entries I want and using debug.print get the output i'm looking for. So, it's nearly a success.
At the present, though, i'm trying to send the qualifying entries to excel - and just the columns i'm after. Only problem i have is that no matter what I do, it doesn't seem to move down to the second level. I'm fairly sure the problem is that in order to go down to the next level it re-call's the function it's presently in. As the second part stands now, i can't get the lower level parts/assemblies to make it to excel - meanwhile, though, all the debug.print lines work perfectly.
Private Sub QueryBOMRowProperties(oBOMRows As BOMRowsEnumerator, ItemTab As Long)
If ExcelSession <> True Then
Dim fExcel As Excel.Application
Dim fWB As Workbook
Set fExcel = New Excel.Application
Set fWB = fExcel.Workbooks.Open("R:\Inventor\VBA\blank.xlsx")
ExcelSession = True
fExcel.Visible = True
End If
'Dim MyCount As Integer
ItemTab = ItemTab + 3
' Iterate through the contents of the BOM Rows.
Dim i As Long
For i = 1 To oBOMRows.Count
' Get the current row.
Dim oRow As BOMRow
Set oRow = oBOMRows.Item(i)
'Set a reference to the primary ComponentDefinition of the row
Dim oCompDef As ComponentDefinition
Set oCompDef = oRow.ComponentDefinitions.Item(1)
Dim oPartNumProperty As Property
Dim oDescripProperty As Property
Dim oTagProperty As Property
If TypeOf oCompDef Is VirtualComponentDefinition Then
'Get the file property that contains the "Part Number"
'The file property is obtained from the virtual component definition
Set oPartNumProperty = oCompDef.PropertySets _
.Item("Design Tracking Properties").Item("Part Number")
'Get the file property that contains the "Description"
Set oDescripProperty = oCompDef.PropertySets _
.Item("Design Tracking Properties").Item("Description")
On Error Resume Next
Set oTagProperty = oCompDef.PropertySets _
.Item("User Defined Properties").Item("TAG_NO")
If Len(oTagProperty.Value) > 0 Then
Debug.Print Tab(0); oTagProperty.Value; Tab(20); oDescripProperty.Value; Tab(90); oPartNumProperty.Value; Tab(110); oRow.ItemQuantity; Tab(120); MyCount;
fExcel.Range("B" & MyCount + 9).Select
fExcel.ActiveCell.Value = oTagProperty.Value
fExcel.Range("C" & MyCount + 9).Select
fExcel.ActiveCell.Value = oDescripProperty.Value
fExcel.Range("F" & MyCount + 9).Select
fExcel.ActiveCell.Value = oPartNumProperty.Value
fExcel.Range("G" & MyCount + 9).Select
fExcel.ActiveCell.Value = oRow.ItemQuantity
' MsgBox (oDescripProperty.Value)
MyCount = MyCount + 1
End If
Else
'Get the file property that contains the "Part Number"
'The file property is obtained from the parent
'document of the associated ComponentDefinition.
Set oPartNumProperty = oCompDef.Document.PropertySets _
.Item("Design Tracking Properties").Item("Part Number")
'Get the file property that contains the "Description"
Set oDescripProperty = oCompDef.Document.PropertySets _
.Item("Design Tracking Properties").Item("Description")
On Error Resume Next
' oTagProperty.Value = ""
Set oTagProperty = oCompDef.Document.PropertySets _
.Item("User Defined Properties").Item("TAG_NO")
If Len(oTagProperty.Value) > 0 Then
Debug.Print Tab(0); oTagProperty.Value; Tab(20); oDescripProperty.Value; Tab(90); oPartNumProperty.Value; Tab(110); oRow.ItemQuantity; Tab(120); MyCount;
fExcel.Range("B" & MyCount + 9).Select
fExcel.ActiveCell.Value = oTagProperty.Value
fExcel.Range("C" & MyCount + 9).Select
fExcel.ActiveCell.Value = oDescripProperty.Value
fExcel.Range("F" & MyCount + 9).Select
fExcel.ActiveCell.Value = oPartNumProperty.Value
fExcel.Range("G" & MyCount + 9).Select
fExcel.ActiveCell.Value = oRow.ItemQuantity
'MsgBox (oDescripProperty.Value)
MyCount = MyCount + 1
End If
'Recursively iterate child rows if present.
If Not oRow.ChildRows Is Nothing Then
Call QueryBOMRowProperties(oRow.ChildRows, ItemTab)
End If
End If
Next
ItemTab = ItemTab - 3
'ActiveWorkbook.SaveAs ("R:\drafting\bom\SL-JZ-FABs1r0.xlsx")
'ActiveWorkbook.Close savechanges:=False, FileName:="R:\Inventor\VBA\blank.xlsx"
'activework.Close savechanges:=True, FileName:="R:\\drafting\bom\SL-JZ-FABs1r0.xlsx"
'fExcel.Quit
End Sub
I commented out the file saving in hopes of seeing where the lower level info was going, but I can't tell. Seems to go nowhere.
My guess is that re-calling the queryBOMRowProperties function is messing something up in regards to the excel writing. hence My ExcelSession flag. Still doesn't work with that. Seems like the file should still be open and work, butit's not seeing a file to write to.
I've been thinking i just nned to make a string for the whole thing then send it to another function to export to excel, but converting multiple lines of delimited text is proving frustrating. I know i have to split it into lines, then in each line split up the entries, but it's kicking my butt right now.