CATIA V5 BoM with user properties

Hi everyone,

The following CATScript is part of an assignment to retrieve several "normal" parameters and one user parameter that every CATPart has.
the problem is that it makes more excel files instead of using just one and it always places the information in the same cell. Ideally it should use only one Excel file and increment the row +1 but i can't go any further on my own.
can someone please help me?
-----
Sub CATMain()
' ********* is the current document a CATIA Product **************
If CATIA.Documents.Count = 0 Then
MsgBox "There are no CATIA documents open. Please open a CATIA document and try again.", ,msgboxtext
Exit Sub
End If
If InStr(CATIA.ActiveDocument.Name, ".CATProduct") < 1 Then
MsgBox "The active document is not a Product. Please open a CATIA Product and try again.", ,msgboxtext
Exit Sub
End If
' ************* General declarations for the Active CATIA session *****************
Dim oProdDoc As ProductDocument
Set oProdDoc = CATIA.ActiveDocument
Dim oRootProd As Product
Set oRootProd = oProdDoc.Product
Dim par As Parameters
Set par = oRootProd.UserRefProperties
Dim SinexRef As String
Dim i As Integer
' *************** begin spec tree scroll ******************
Call WalkDownTree(oRootProd)
End Sub
Sub WalkDownTree(oInProduct As Product)
Dim oInstances As Products
Set oInstances = oInProduct.Products
On Error Resume Next
Set Excel = GetObject(, "EXCEL.Application")
If Err.Number < 1 Then
Set Excel = CreateObject("EXCEL.Application")
Excel.Visible = True
Excel.Workbooks.Add
End If
for i=1 to oInProduct.Count
row=2
'**************************** Export title ***************************
col=1
Excel.Columns.Columns(1).Columnwidth = 5
Excel.Columns.Columns(2).Columnwidth = 15
Excel.Cells(row,col+1).Font.Bold = true
Excel.Cells(row,col+1).HorizontalAlignment = 3
Excel.Cells(row, col+1).Value = "Exportation of:"
Excel.Cells(row,col+2).Value = CATIA.ActiveDocument.Name
' **************************** Export column titles ***************
row=row+2
Excel.Cells(row,col+1).Font.Bold = true
Excel.Columns.Columns(2).Columnwidth = 20
Excel.Cells(row,col+1).borders.LineStyle = 1
Excel.Cells(row,col+1).HorizontalAlignment = 3
Excel.Cells(row,col+1).Value = "Part Name"
Excel.Cells(row,col+2).Font.Bold = true
Excel.Columns.Columns(3).Columnwidth = 15
Excel.Cells(row,col+2).borders.LineStyle = 1
Excel.Cells(row,col+2).HorizontalAlignment = 3
Excel.Cells(row,col+2).Value = "Ref."
Excel.Cells(row,col+3).Font.Bold = true
Excel.Columns.Columns(4).Columnwidth = 15
Excel.Cells(row,col+3).borders.LineStyle = 1
Excel.Cells(row,col+3).HorizontalAlignment = 3
Excel.Cells(row,col+3).Value = "Quantity"
Excel.Cells(row,col+4).Font.Bold = true
Excel.Columns.Columns(5).Columnwidth = 15
Excel.Cells(row,col+4).borders.LineStyle = 1
Excel.Cells(row,col+4).HorizontalAlignment = 3
Excel.Cells(row,col+4).Value = "Sinex Ref."
' **************************** Export table values ***************
Excel.Cells(row+2,col+1).Value = oInProduct.PartNumber
Excel.Cells(row+2,col+2).Value = oInProduct.Nomenclature
Excel.Cells(row+2,col+2).HorizontalAlignment = 3
Excel.Cells(row+2,col+3).Value = oInProduct.Nomenclature.Count
Excel.Cells(row+2,col+3).HorizontalAlignment = 3
Excel.Cells(row+2,col+4).Value = oInProduct.Nomenclature.SinexRef
Excel.Cells(row+2,col+4).HorizontalAlignment = 3
Next
row=row+3
Dim k As Integer
For k = 1 To oInstances.Count
Dim oInst As Product
Set oInst = oInstances.Item(k)
Call WalkDownTree(oInst)
Next
End Sub

Answer
 
Comments 0