Save Part with New Name Example
This example shows how to load an existing
SolidWorks part and save it with a new name.
'---------------------------------------------
Sub Main( )
Dim swApp As Object
Dim Model As Object
Dim errors As Long
MyPath = CurDir
Set swApp = CreateObject("SldWorks.Application")
Set Model = swApp.OpenDoc(MyPath
+ "\Parametric.PRT", swDocPART)
If Model Is Nothing Then
Exit Sub
Else
Set Model= swApp.ActivateDoc2("Parametric.PRT",
True, errors)
End If
newname = MyPath + "\FRED.PRT"
If (Model.SaveAs(newname))
Then
Msg = "Part Saved As
" + newname
' Button option
shows OK only
Style = vbOKOnly
Title = "Note!"
' Define title.
Call MsgBox(Msg, Style,
Title) ' Display message to user
End If '
End if SaveAs is successful
' Close the document
swApp.CloseDoc
newname
swApp.ExitApp
End Sub