Ask Your Question
0

Error: Err:508 problem while writing macro(setFormula) with libreoffice basic

asked 2016-08-10 07:40:36 +0200

mustafaxfe gravatar image

updated 2016-08-10 07:42:24 +0200

Hi,

I have started to write a macro to organize my file as I want. I am going to finish it but I have locked a problem.

When I try to write a formula with setFormula, it gives that error Err:508

My Formula: oCellYD.setFormula("=IF((M" & i & "<>"""")," & "O" & i & ",0)")

It looks oCellYD.setFormula("=IF((M" & i & "<>")," & "O" & i & ",0)") as in libreoffice input line. So adding a " in the middle '<> "' => '<> ""' of formula by hand at input line it fixes.

And also when I Change my formula as oCellYD.setFormula("=IF((M" & i & "<>"")," & "O" & i & ",0)")

It gives #NAME? error. And If add a quotation mark as in Err:508, It fixes.

So my question, how can I fix this issue in macro.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2016-08-10 16:47:41 +0200

Ratslinger gravatar image

The problem lies in your formula syntax. The correct syntax is =IF((M" & i & "<>"""");" & "O" & i & ";0)

When entering a formula directly into a cell, it is using the , because Options for Calc are stated so. However, when you move the formula into a cell from a macro, it need the correct separator - ;. That is why when adding a change directly to the cell works - it then accepts the , as the separator.

edit flag offensive delete link more

Comments

Thanks for your time. My issue is fixed. Thank you...

mustafaxfe gravatar imagemustafaxfe ( 2016-08-11 04:27:01 +0200 )edit

I have the same problem. I thought this was the answer, but it isn't. When I use ;'s in the macro, it still shows up in the spreadsheet as ,'s in the value for the cell and displays as Err: 508. If I press Enter in the edit field, it then formats correctly (as a date in my case). F9 or Shift-Ctrl-F9 do not fix it. To look at the contents of the cell, there is no difference between before the Enter and after. Also, 508 is supposed to be unmatched parentheses.

Kenneth Evans gravatar imageKenneth Evans ( 2017-11-15 22:32:01 +0200 )edit

My mistake. I missed one of the ,'s. So this is the solution. Thanks.

Kenneth Evans gravatar imageKenneth Evans ( 2017-11-15 22:53:16 +0200 )edit
Login/Signup to Answer

Question Tools

2 followers

Stats

Asked: 2016-08-10 07:40:36 +0200

Seen: 354 times

Last updated: Aug 10 '16