Sub CATMain()
Dim i, n As Integer
Dim name, prt As String
Dim BodyName() As String
Dim partDocument1 As PartDocument
On Error Resume Next
Set partDocument1 = CATIA.ActiveDocument
name = partDocument1.FullName
Dim part1 As Part
Set part1 = partDocument1.Part
Dim bodies1 As Bodies
Set bodies1 = part1.Bodies
Dim body1 As Body
Dim sel As Selection
Set sel = partDocument1.Selection
Dim documents2 As Documents
Dim partDocument2 As PartDocument
Dim part2 As Part
Dim specsAndGeomWindow1 As SpecsAndGeomWindow
n = bodies1.Count
prt = Left(partDocument1.name, Len(partDocument1.name) - 8)
For i = 1 To n
ReDim Preserve BodyName(i)
BodyName(i) = bodies1.Item(i).name
Set partDocument1 = CATIA.ActiveDocument
sel.Clear
sel.Add bodies1.Item(i)
sel.Copy
Set documents2 = CATIA.Documents
Set partDocument2 = documents2.Add("Part")
partDocument2.Product.PartNumber = BodyName(i)
Set partDocument2 = CATIA.ActiveDocument
Set specsAndGeomWindow1 = CATIA.ActiveWindow
Set part2 = partDocument2.Part
sel.Add part2
sel.PasteSpecial ("CATPrtResultWithOutLink")
part2.Update
Set partDocument2 = CATIA.ActiveDocument
partDocument2.ExportData Left(name, Len(name) - Len(partDocument1.name)) & BodyName(i) & ".igs", "igs"
specsAndGeomWindow1.Close
partDocument2.Close