9 Replies Latest reply on Jun 4, 2014 11:20 AM by Deepak Gupta

    Save Macro

    Michael Ferraro

      Hello Everyone!


      I have attached a macro that I was working on.


      The intention of this macro is to open each drawing file in a specified folder (by the user) and save that drawing folder into 2 locations on our server.

           Which inside the macro I call out as MDLPath and WDJPath


      And in the event that it has a revision it will add that revision to the saved file name.

           Ex. Part1 with rev A will be saved as Part1-A


      However I cannot seem to get this thing to work. I keep getting an error


      Run-time error '91':

      Object variable or With block variable not set.


      I thought I had fixed it but I cant seem to get this to work.


      I was wondering if anyone would be able to help me out and help fix my issue.

      I realize I may have some lines of code in the wrong position and it could be as simple as this needs to be moved up a few lines.


      Thanks in advance!



        • Re: Save Macro
          Artem Taturevych

          Hello Michael,


          Try to change to the following in your code where you are closing the file:


          If Not swModel Is Nothing Then

              swApp.CloseDoc swModel.GetTitle

          End If


          Regards, Artem Taturevych | Snr. Developer | IC3D ANZ


          IC3DSteel – New Steel Solution for SolidWorks

          LinkedIn - SolidWorks API Group

          • Re: Save Macro
            Christopher Estelow

            *********  EDIT: This will only copy .slddrw files, it will not convert them to another format*********



               It can easily be done with a macro but couldn't you just copy the files through windows explorer instead of opening up each one and saving it in Solidworks?  Here is a batch file you can use to do it with just a double click and its fast.  Copy the code below and put it in notepad, change the "Destination Folder Locations" of the two folders you want to copy to then save it as YourNameHere.bat (remove the .txt).  Put the .bat file in the same folder you are trying to copy the drawing files from and double click it. It will create a copy of each file with the .slddrw file extension to each of the destination folders.



            for %%o in (.slddrw) do copy "*%%o" "Destination Folder location1"

            for %%o in (.slddrw) do copy "*%%o" "Destination Folder location2"


            This will be a lot quicker in my opinion.