2 Replies Latest reply on Oct 18, 2013 6:04 PM by Artem Taturevych

    Check if excel is open

    Brian Mick



      I have a macro that opens an excel spreadsheet and writes some values from the solidworks custom properties to the spreadsheet.  If I run the macro on multiple parts without saving and closing the spreadsheet each time, the macro tries to open a new copy of the spreadsheet.  Is there any way to test if the spreadsheet is already open?


      Here is my code that opens the spreadsheet:


      Set xlApp = CreateObject("Excel.Application")


      Set xlWorkbook = xlApp.Workbooks.Open("\\SERVER1\Engineering\Prototype Parts in Production List.xlsx")


      Set xlWorksheet = xlWorkbook.Worksheets(1)


      xlApp.Visible = True


      Thanks in advance for any help!