mirror of
https://github.com/dfinke/ImportExcel.git
synced 2025-12-10 05:13:49 +00:00
use try-finally
This commit is contained in:
@@ -45,11 +45,15 @@ function ConvertTo-ExcelXlsx {
|
|||||||
throw "Could not create Excel.Application ComObject. Please verify that Excel is installed."
|
throw "Could not create Excel.Application ComObject. Please verify that Excel is installed."
|
||||||
}
|
}
|
||||||
|
|
||||||
$Excel.Visible = $false
|
try {
|
||||||
$null = $Excel.Workbooks.Open($xlsFile.FullName, $null, $true)
|
$Excel.Visible = $false
|
||||||
$Excel.ActiveWorkbook.SaveAs($xlsxPath, $xlFixedFormat)
|
$null = $Excel.Workbooks.Open($xlsFile.FullName, $null, $true)
|
||||||
$Excel.ActiveWorkbook.Close()
|
$Excel.ActiveWorkbook.SaveAs($xlsxPath, $xlFixedFormat)
|
||||||
$Excel.Quit()
|
}
|
||||||
|
finally {
|
||||||
|
$Excel.ActiveWorkbook.Close()
|
||||||
|
$Excel.Quit()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user