API: Silent Save

Jan 23, 2007 2 Replies

I created the macro below to do a silent save but as you can see from the code it actually launches two saves, one to save the active doc and one to save the referenced docs. Can someone please show me how to change the code so that the active doc and referenced docs are all saved with one save?



Thanks



Sub main()



Dim swApp As Object Dim SaveOptions As Long Dim SaveSuccess As Boolean Dim Modeldoc As SldWorks.ModelDoc2 Dim DocErrors As Long Dim DocWarnings As Long Dim DocOptions As Long



Set swApp = Application.SldWorks Set Modeldoc = swApp.ActiveDoc



SaveOptions = swSaveAsOptions_Silent SaveSuccess = Modeldoc.Save3(SaveOptions, DocErrors, DocWarnings) 'Save parent doc



SaveOptions = swSaveAsOptions_SaveReferenced SaveSuccess = Modeldoc.Save3(SaveOptions, DocErrors, DocWarnings) 'Save referenced docs



End Sub



Sam,

I didn't test this, but did you try just combining your options like this?

Sub main()

Dim swApp As Object Dim SaveOptions As Long Dim SaveSuccess As Boolean Dim Modeldoc As SldWorks.ModelDoc2 Dim DocErrors As Long Dim DocWarnings As Long Dim DocOptions As Long

Set swApp = Application.SldWorks Set Modeldoc = swApp.ActiveDoc

SaveOptions = swSaveAsOptions_Silent SaveOptions = SaveOptions + swSaveAsOptions_SaveReferenced SaveSuccess = Modeldoc.Save3(SaveOptions, DocErrors, DocWarnings)

End Sub

Sam wrote:

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required