Code:
Sub CATMain()Dim DEBUG As Boolean
DEBUG = FALSE
CATIA.DisplayFileAlerts = False
Catia.Statusbar = "Starting Main-Program -> " & FUNC_NAME & " ( " & VERSION & " ) "
Set ActiveDoc = CATIA.ActiveDocument
REM---------------------------
REM Document check
REM---------------------------
If Err.Number <> 0 Then
	CHECK = MsgBox ( " No Document is opened !", 16, FUNC_NAME & "  " & VERSION )
	Exit Sub
End If 
REM---------------------------
REM Calculate Bill of Material in the active
REM Product ( ActivePro )
REM---------------------------
ReDim BoMList ( 99999, 4 )
Set ActiveDoc = CATIA.ActiveDocument
Set ActivePro = ActiveDoc.Product
iList = 1
call CalcBoM ( ActivePro, BoMList, iList, Name )
Set FileSystem1=CATIA.FileSystem
Set File1 = FileSystem1.CreateFile( "C:\BomList_1.csv", True )
Set TextStr1 = File1.OpenAsTextStream ("ForWriting")
For i = 1 To iList
	Dummy = i & ";" & BoMList ( i,0 ) & ";" & BoMList ( i,1 ) & ";" & BoMList ( i,2 ) & ";" & BoMList ( i,3 )
	TextStr1.Write Dummy & Chrw(10)
Next
TextStr1.Close
End Sub
REM---------------------------------------------------------------------------------
Function CalcBoM ( CurProduct, BoMList, iList, Name )
FUNC_NAME = "CalcBoM"
Catia.Statusbar =  "Function " & FUNC_NAME
Dim A(11) As Double
Dim sArray As Array
Name = Name & ";" & CurProduct.Name
imax = CurProduct.Products.count
If ( imax = 0 ) Then
	PartName = CurProduct.Name
	CurProduct.Position.GetComponents A
	sArray = split ( PartName, "." )
	PartName = sArray (0)
	BoMList ( iList, 0 ) = Name
	BoMList ( iList, 1 ) = A(9)
	BoMList ( iList, 2 ) = A(10)
	BoMList ( iList, 3 ) = A(11)
	iList = iList + 1
	Name = ""
Rem	Catia.Statusbar =  "Function " & FUNC_NAME & " -> " & PartName & " / " & A(9) & " / " & A(10) & " / " & A(11)
	Exit Function
Else
	Dummy = Name
	For i = 1 to imax
		call CalcBoM ( CurProduct.Products.Item(i), BoMList, iList, Name )
		If i <> imax Then Name = Dummy
	Next
End If
End Function