Copy formula into a cell programattically

Hello everyone,

Just out of curiosity, the first code works, the second one gives me Err:508


with ThisComponent.sheets.getByName("Sheet1")
    .getCellRangeByName("e1").formula = "=b3+b4"
end with


with ThisComponent.sheets.getByName("Sheet1")
   .getCellRangeByName("e1").formula = "=iferror(b3+b4,"""")"
end with

When I edit the cell, it shows the formula properly, but it does not calculate.

When I type in that formula into a different cell, and then programmatically copy formula form one cell to the next, it works just fine as well.

Thank you in advance, for your help.

[erAck: edited to insert a blank line after 1st/2nd to actually format the next paragraph as indented code]



Use a semicolon (;) as argument separator, i.e "=iferror(b3+b4;""""), if you insert a formula using a macro.

Tested using LibreOffice:

Version: / LibreOffice Community
Build ID: 85f04e9f809797b8199d13c421bd8a2b025d52b5
CPU threads: 8; OS: Linux 5.3; UI render: default; VCL: kf5
Locale: en-US (en_US.UTF-8); UI: en-US; Calc: threaded

Hope that helps.

Awesome, thank you for your help!