5 Replies Latest reply on May 2, 2017 8:43 AM by Deepak Gupta

    Solidworks Screen Capture

    Micah Burney

      hello everyone! I am new to macro and api's. i need help with just a segment of code that's causing me problems.


      - i have a website that takes the customers inputs which activates Excel.

      - Excel then executes my macro created with vba which then executes solidworks.

      - the given inputs from the customers are created through geometry in solidworks.


      how would write some code to take a screen capture of the current view

      save that image as a jpeg and set it to an specific directory

      then echo print that image back to URL (website)



      if anyone can help thank you in advance

        • Re: Solidworks Screen Capture
          Christian Chu

          Sure you can save your SW screen to jpeg file - see att. code - as it's saved the jpeg file to your working directory but you can point to diff. folder


          Dim swDwg As SldWorks.DrawingDoc 

              Set swDwg = swApp.ActiveDoc

              Dim longstatus As Long

              Dim longwarnings As Long

              Dim longerrors As Long

              Dim bret As Boolean

              Dim sFullName As String

              sFullName = swDwg.GetPathName()

              sPictName = Replace(sFullName, ".SLDDRW", ".jpg", 1, -1, vbTextCompare)

              bret = swDwg.SaveAs4(sPictName, 0, swSaveAsOptions_Silent, longerrors, longwarnings)