2 Replies Latest reply on May 12, 2015 10:48 AM by Alice Caspari

    How to Cancel SaveAs Dialog

    Alice Caspari

      I am trying to do a SaveAs on a drawing without saving any referenced files. The Macro below works for that but it pops up a dialog box prompting to save the part, which needs to be canceled. Is there a way to Cancel the dialog through the API?

       

       

      Option Explicit

       

        

      Dim swApp As Object

      Dim swModel As ModelDoc2

      Dim Part As ModelDocExtension

      Dim bool As Boolean

      Dim fileNamePath As String

      Dim longstatus As Long, longwarnings As Long

       

      Sub main()

      Set swApp = Application.SldWorks

      Set swModel = swApp.ActiveDoc

      Set Part = swModel.Extension

      fileNamePath = "K:\Engineering\ALC\CONFIGURATOR\TestSave3-1.SLDDRW"

        

       

      bool = Part.SaveAs(fileNamePath, swSaveAsCurrentVersion, (swSaveAsOptions_Copy & swSaveAsOptions_Silent), Nothing, 0, 0)

       

      End Sub

       

        • Re: How to Cancel SaveAs Dialog
          Keith Rice

          When I do save as copy on a drawing I am not prompted to save the dependents, so I am not able to recreate your scenario that you seem to be describing.

           

          Anyway, there is a mistake in your code that you should fix, though I don't know whether it will resolve your original problem. Change this line:

          bool = Part.SaveAs(fileNamePath, swSaveAsCurrentVersion, (swSaveAsOptions_Copy & swSaveAsOptions_Silent), Nothing, 0, 0)
          

           

          To this line, where the ampersand is now a plus sign:

          bool = Part.SaveAs(fileNamePath, swSaveAsCurrentVersion, (swSaveAsOptions_Copy + swSaveAsOptions_Silent), Nothing, 0, 0)
          

           

          The Options argument uses bitmasking to determine the options said, and rather than telling it that you want option "3", which copies and saves silent, you are telling it you want option "21", which updates inactive views, saves referenced models, and saves silent.

           

          Keith

          SolidWorks API Tutorials