API: Silent Save

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

Reply to
Sam
Loading thread data ...

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:

Reply to
fcsuper

This seems to have worked, Thanks

Reply to
Sam

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.