Rename Save Name Macro - tip

By jzecha

Does anybody have a macro that cycles through all the parts and products and saves them using their in session Part Number? I have the opposite Macro that renames the in session Part Number to the save name.
If anybody is interested, I figured it out. Here is the code, it works exactly how I needed it too. Enjoy.

CODE --> CATScript

Sub CATMain()

CATIA.DisplayFileAlerts = False

Set oDocs = CATIA.Documents
docPath = oDocs.Item(1).Path
changePath = MsgBox(“Current save location is: " & docPath & " Would you like to change file path?”, vbYesNo)

If changePath = vbYes Then
docPath = InputBox(“Enter new file path”, “File path”)
End If

For x = 1 To oDocs.Count

If TypeName(oDocs.Item(x)) = “ProductDocument” Then
Set oDoc1 = oDocs.Item(x)
Set oProduct1 = oDoc1.Product
oDoc1.SaveAs docPath & “” & oProduct1.PartNumber & “.CATProduct”
End If
Next 'x

For v = 1 To oDocs.Count

If TypeName(oDocs.Item(v)) = “PartDocument” Then
Set oDoc2 = oDocs.Item(v)
Set oPart1 = oDoc2.Product
oDoc2.SaveAs docPath & “” & oPart1.PartNumber & “.CATPart”
End If
Next 'v

Msgbox “Save Finished!”,“SAVE FINISH!”

End Sub