Check if Excel workbook is open with VBScript

I have a vbs script that writes to an Excel spreadsheet. To save the spreadsheet, I need to make sure that it is not open yet. Can anyone suggest a better way to do this?

Some studies:

  • I tried to create Word Tasks objects to show me all running processes, but in Windows 7 it only tells me whether Excel works or not.
  • Creating an Excel.Application object does not give me access to all running instances of Excel.
  • I was thinking about opening a spreadsheet for writing, but the only way I can do this is to use the OpenTextFile method for the file system object, which does not seem to be the right approach since the Excel file is binary.

Any other ideas?

+3
source share
1 answer

Since the Excel.Application object does not give you access to all instances of Excel, how about using a simple error trap? i.e. if it cannot save the file, throw a warning, save as a different file name, etc.

0
source

Source: https://habr.com/ru/post/1768259/


All Articles