I need help creating a PowerShell script that will find all open Excel documents, then first if the document is read only close the document without saving and suppress prom
Set xlBook = GetObject("C:\Users\David Candy\Documents\Super.xls", "Excel.Application")
For each wsheet in xlbook.worksheets
msgbox wsheet.name
next
VBScript, JScript, PS, VBA can all do it. Above is VBScript (and thus also VBA). The technology is COM not a language.
EDIT
As said using the app object doesn't work in excel.
A excel file opened.
EXCEL.EXE 13560 Console 1 19,228 K Running DESKTOP-UCDGI39\David Candy
0:00:00 Microsoft Excel - Super.xls
Running GetObject using Excel.Application
EXCEL.EXE 13560 Console 1 19,236 K Running DESKTOP-UCDGI39\David Candy
0:00:00 Microsoft Excel - Super.xls
EXCEL.EXE 15124 Console 1 12,772 K Running DESKTOP-UCDGI39\David Candy
0:00:00 N/A
NOTE
This is in addition to other faulty behaviour by excel where it won't exit memory when references are released.