Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rename Save Name Macro 1

Status
Not open for further replies.

jzecha

Aerospace
Jan 20, 2016
235
US
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.
 
Replies continue below

Recommended for you

If anybody is interested, I figured it out.
Here is the code, it works exactly how I needed it too.

Code:
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top