Merge pull request #1603 from edwardmiller-mesirow/read-only

[ConvertTo-ExcelXlsx] open XLS as read-only
This commit is contained in:
Doug Finke
2024-05-18 09:37:38 -04:00
committed by GitHub

View File

@@ -45,11 +45,18 @@ function ConvertTo-ExcelXlsx {
throw "Could not create Excel.Application ComObject. Please verify that Excel is installed."
}
$Excel.Visible = $false
$null = $Excel.Workbooks.Open($xlsFile.FullName)
$Excel.ActiveWorkbook.SaveAs($xlsxPath, $xlFixedFormat)
$Excel.ActiveWorkbook.Close()
$Excel.Quit()
try {
$Excel.Visible = $false
$null = $Excel.Workbooks.Open($xlsFile.FullName, $null, $true)
$Excel.ActiveWorkbook.SaveAs($xlsxPath, $xlFixedFormat)
}
finally {
if ($null -ne $Excel.ActiveWorkbook) {
$Excel.ActiveWorkbook.Close()
}
$Excel.Quit()
}
}
}