Code:
Sub CATmain()
CATIA.DisplayFileAlerts = False
Dim myproduct As Product
dim Doc as document
Set myproduct = CATIA.ActiveDocument.Product
set Doc = myproduct.referenceproduct.parent
' Enter Absolute Savepath here
Dim bsppath As String
bsppath = "G:\exchange\TEST-DIE_MACRO\Neuer Ort\"
Dim Abssavepath As String
Abssavepath = InputBox("Please enter the Absolute Save Path", "Save Path", bsppath)
' Launch the SAVEROUTINE
Savethisdocument myproduct, Abssavepath
' Save Mainproduct
Doc.SaveAs (Abssavepath & myproduct.PartNumber & Right(Doc.Name, Len(Doc.Name) - InStrRev(Doc.Name, ".") + 1))
CATIA.DisplayFileAlerts = True
' On end
MsgBox "Finished"
End Sub
Sub Savethisdocument(Myprod As Product, Abssavepath As String)
Dim currentprod As Product
Dim Doc As Document
On Error Resume Next
For i = Myprod.Products.Count To 1 Step -1
Set currentprod = Myprod.Products.Item(i)
Set Doc = currentprod.ReferenceProduct.Parent
If currentprod.Products.Count <> 0 Then
Err.Clear
Savethisdocument currentprod, Abssavepath
Doc.SaveAs (Abssavepath & currentprod.PartNumber & Right(Doc.Name, Len(Doc.Name) - InStrRev(Doc.Name, ".") + 1))
else
Doc.SaveAs (Abssavepath & currentprod.PartNumber & Right(Doc.Name, Len(Doc.Name) - InStrRev(Doc.Name, ".") + 1))
End If
If Err.Number <> 0 Then
MsgBox (Err.Description)
End If
MsgBox ("I am Here: " & currentprod.PartNumber)
Next
On Error GoTo 0
End Sub