1 Reply Latest reply on Jul 27, 2016 1:43 PM by Deepak Gupta

    swApp vs Application.SldWorks

    Terell Dunn

      I'm new to programming. I tried searching for this in SolidWorks specific terms and more broad VBA terms, but I couldn't find an answer.


      I understand swApp is arbitrary and could be anything. This also goes for swModel, swAssy, ect...


      I've noticed Excel macros are the same way. excelApp = Application.Excel


      What are the reasons behind setting swApp = Application.SldWorks and using swApp throughout a macro instead of just typing Application.SldWorks  when necessary?


      Thanks for the information.

        • Re: swApp vs Application.SldWorks
          Deepak Gupta

          As you rightly said that swApp is arbitrary and could be anything. The only reason I understand is that instead of using Application.SldWorks, you've define a variable for it (for e.g. swApp or anything) and then use in the codes to make the codes less clustered.


          For e.g. instead of using Application.SldWorks.ActiveDoc, you define this as swModel which makes the coding looks cleaner.