1 Reply Latest reply on May 9, 2016 4:38 PM by Alfred Jelinek

    Macro to delete old/temp assembly files from working directory

    Alfred Jelinek

      I have created a macro to take my main assy file which contains subs with parts( the parts being in Part library on the c drive)...and saving all new assemblies subs parts with a prefix while also changing all references to point all files to the working directory rather than the library locations.

       

      What I need is a small macro I can add to the end of my macro that will delete four temporary assembly files:

       

      the location of the files is:

      "C:\Users\aljel\Desktop\test\"

       

      the four files are:

      123456-Main_Die_Assy.sldasm

      123456-Upper_Die_Assy.sldasm

      123456-Middle_Die_Assy.sldasm

      123456-Lower_Die_Assy.sldasm

       

      With this info/macro/code....I will be able to complete my massive macro.

       

      Thank you for your time and help!!!

       

      Al Jelinek

        • Re: Macro to delete old/temp assembly files from working directory
          Alfred Jelinek

          I found the answer online...at:

          VBA - Delete files and folders - Felicini

           

          I used this for code:

          Sub main()

          'Deletes...permanently...no recycle bin.... the four temp assy files in the folder working directory
              On Error Resume Next
              Kill "C:\Users\aljel\Desktop\test\123456-Main_Die_Assy.sldasm"
              Kill "C:\Users\aljel\Desktop\test\123456-Upper_Die_Assy.sldasm"
              Kill "C:\Users\aljel\Desktop\test\123456-Middle_Die_Assy.sldasm"
              Kill "C:\Users\aljel\Desktop\test\123456-Lower_Die_Assy.sldasm"
              On Error GoTo 0

          End Sub

           

           

          I will eventually add in a "myPath" to replace the location...and other to replace the 123456-....stuff

           

          But it does what I needed it to do.