API: Silent Save

Discussion in 'SolidWorks' started by Sam, Jan 23, 2007.

  1. Sam

    Sam Guest

    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, Jan 23, 2007
    #1
  2. Sam

    fcsuper Guest

    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
     
    fcsuper, Jan 23, 2007
    #2
  3. Sam

    Sam Guest

    This seems to have worked, Thanks
     
    Sam, Jan 24, 2007
    #3
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.