From b8049f6f850660431009bc83c38e77b1db45bea7 Mon Sep 17 00:00:00 2001 From: "Bobby Abellana (aider)" Date: Fri, 21 Feb 2025 11:03:55 -0800 Subject: [PATCH] refactor: Replace SaveAs2 with standard SaveAs method in Excel conversion --- SharePointFunctions.ps1 | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/SharePointFunctions.ps1 b/SharePointFunctions.ps1 index af99555..bbe0bb1 100644 --- a/SharePointFunctions.ps1 +++ b/SharePointFunctions.ps1 @@ -494,22 +494,8 @@ function Convert-Files { $xlOpenXMLWorkbook = 51 # Excel constant for XLSX format $xlNormal = 1 # Excel constant for normal save - # Use the Excel Application SaveAs2 method - $workbook.SaveAs2( - $excelXlsxPath, - $xlOpenXMLWorkbook, # FileFormat = xlsx - $null, # Password - $null, # WriteResPassword - $false, # ReadOnlyRecommended - $null, # CreateBackup - $xlNormal, # AccessMode - $null, # ConflictResolution - $true, # AddToMru - $null, # TextCodepage - $null, # TextVisualLayout - $false # Local - ) - + # Use the standard SaveAs method + $workbook.SaveAs($excelXlsxPath, $xlOpenXMLWorkbook) $workbook.Close($true) # True to save changes Start-Sleep -Seconds 2 # Give Excel more time to finish saving