4 Replies Latest reply on Feb 12, 2015 2:49 PM by Heinz Navratil

    Excel Object

    Dave Olson

      I've prepared a SolidWorks macro (snippets below) that references an Excel workbook. Upon completion of the macro, I exit the Excel application and free the memory associated with the Excel object. I've used this process successfully in many other applications. In SolidWorks, the Excel application continues to reside in the Task Manager (thus locking the spreadsheet). The Excel process must be manually killed from Task Manager to close the workbook and terminate Excel. I don't want to add code to indiscriminately kill an Excel process in case another sheet is open. Does anyone know why the worksheet isn't closed from within SolidWorks?

      Dim xlApp As Object
      Set xlApp = CreateObject("Excel.Application")
      Do Things
      xlApp.DisplayAlerts = False
      Set xlApp = Nothing

        • Re: Excel Object
          Keith Rice



          This has long been a problem. See my blog post Using Microsoft Excel with the SolidWorks API for how to ensure that the EXCEL.EXE process will end without blunting killing the process using TASKKILL.


          By the way, to make this thread easier to find for others with this problem, please consider renaming it to "EXCEL.EXE process remains in Task Manager" or something more specific than your current title.



          SolidWorks API Training

          • Re: Excel Object
            Heinz Navratil

            Hi Dave,

            I had the same problem, I found the following solution in the WWW which works fine for me


            as you have a connection to excel like


                        exc = CreateObject("Excel.Application")

                        exc.Visible = False

                        wbs = exc.Workbooks








            Private Sub releaseObject(ByVal obj As Object)



                        obj = Nothing

                    Catch ex As Exception

                        obj = Nothing



                    End Try

            End Sub