I use Invoke-Item "some-file.xlsx" to launch Excel and open a file. Now I would like to open this file in read only mode. It this possible from PowerShell?
To clearify, I am not looking to open the Excel sheet and read data from it to the PowerShell script, the script is intended to help the user finding a file and opening it.
$objWorkbook = $objExcel.Workbooks.Open($excelfile, 2, $True)Invoke-Item "some-file.xlsx". I think the $objExcel.Workbooks.Open() will open the Excel file in the scope of te PowerShell script only. Closing the PowerShell will close the Excel sheet.Exception calling "Add" with "0" argument(s): "Old format or invalid type library. (Exception from HRESULT: 0x80028018. This error has a workaround, but it is a lot of COM+ fiddling. I hope there is a non-COM+ way to do this.