Populating Excel cell with powershell returns 0x800A03EC

Viewed 26

I'm populating multiple cells in Excel with data from Powershell, but three of them fails everytime, the only difference between the ones that work and those that don't are the formulas to populate the cell with.

The three Excel functions that don't work is below:

    $WorkSheetStatus.Columns.Item(2).Rows.Item(1) = '="Idag " & TEXT(OneDrive!B1; "åå-MM-dd")'
    $WorkSheetStatus.Columns.Item(10).Rows.Item(1) = '="Skillnad mellan " & TEXT(OneDrive!D1; "åå-MM-dd") & " - " & TEXT(OneDrive!B1; "åå-MM-dd")'
    $WorkSheetStatus.Columns.Item(18).Rows.Item(1) = '="((" & TEXT(OneDrive!P1; "åå-MM-dd") & " - " & TEXT(OneDrive!D1; "åå-MM-dd") & ")/7) - " & TEXT(OneDrive!B1; "åå-MM-dd")'

Exception from HRESULT: 0x800A03EC

It throws the below error on all three:

Undantag från HRESULT: 0x800A03EC At C:\Users\Alexander\Downloads\Backup_report.ps1:305 char:5
+     $WorkSheetStatus.Columns.Item(2).Rows.Item(1) = "=""Idag "" & TEX ...
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (:) [], COMException
    + FullyQualifiedErrorId : System.Runtime.InteropServices.COMException

I have also tried enclosing the formula in double quotes and adding them to seperate variables, but nothing seems to work.

But if i copy and paste the formulas in Excel they work, any help would be very much appreciated.

1 Answers

I found the issue, the issue seemed to be with the localization of the formulas.

I tried entering the formulas with Swedish localization, in which we use semicolon instead of regular commas, i changed the semicolons in the formulas to commas and now it works.

Related