[Solved] .Formula("=WORKDAY(now(), 3) problem

Creating a macro - Writing a Script - Using the API

[Solved] .Formula("=WORKDAY(now(), 3) problem

Postby niall » Thu Apr 09, 2009 3:27 pm

Hi I have OO 3.0.1 on winXP and am trying to change a macro to write a formula into a cell.
...
oCell=oSheet.getCellByPosition(0,38) 'A30
oCell.Formula = "=WORKDAY(now();3)"

When I run th emacro I get the following in the cell:
=workday(NOW();3)

In addition I get get non ASCII characters displayed in the worksheet itself at that cell position. Is there a bug in Calc that it is making the first function appear all in lowercase ?. I have tried different functions and it is always the same.

Help,

Niall
Last edited by Hagar Delest on Fri Apr 10, 2009 11:50 am, edited 1 time in total.
Reason: tagged [Solved].
OOo 3.0.X on Ms Windows XP
niall
 
Posts: 3
Joined: Thu Apr 09, 2009 3:20 pm

Re: .Formula("=WORKDAY(now(), 3) problem

Postby niall » Thu Apr 09, 2009 4:17 pm

Meant to say that because the formula is inserted into the cell in lowercase it will not evaluate.

N.
OOo 3.0.X on Ms Windows XP
niall
 
Posts: 3
Joined: Thu Apr 09, 2009 3:20 pm

Re: .Formula("=WORKDAY(now(), 3) problem

Postby Villeroy » Thu Apr 09, 2009 4:54 pm

Put the formula manually into the cell and call

print oCell.getFormula() => =com.sun.star.sheet.addin.Analysis.getWorkday(NOW();3)
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
User avatar
Villeroy
Volunteer
 
Posts: 29580
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: .Formula("=WORKDAY(now(), 3) problem

Postby turtle47 » Thu Apr 09, 2009 5:06 pm

Hi niall,

try
Code: Select all   Expand viewCollapse view
oCell.Formulalocal = "=WORKDAY(NOW();3)"


Good luck

Jurgen
OOo 3.2.X on Ms Windows 7
turtle47
 
Posts: 31
Joined: Tue Sep 16, 2008 3:54 pm

Re: .Formula("=WORKDAY(now(), 3) problem

Postby niall » Fri Apr 10, 2009 10:35 am

Thanks Jurgen & Villeroy,
In the end I used Jurgen's solution.

.Formulalocal(....) worked perfectly. Thanks you

Thanks,

Niall
OOo 3.0.X on Ms Windows XP
niall
 
Posts: 3
Joined: Thu Apr 09, 2009 3:20 pm

Re: .Formula("=WORKDAY(now(), 3) problem

Postby Villeroy » Fri Apr 10, 2009 11:03 am

niall wrote:Thanks Jurgen & Villeroy,
In the end I used Jurgen's solution.

.Formulalocal(....) worked perfectly. Thanks you

Thanks,

Niall

Mind that property FormulaLocal is specific to the user interface language. It puts the same string as a user would type into the formula bar. Your macro would fail to put the correct formula in any non-English version.
cell.Formula "=com.sun.star.sheet.addin.Analysis.getWorkday(NOW();3)" does the job in all OOo installations around the world.
cell.FormulaLocal = "=WORKDAY(NOW();3)" assumes English user interface.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
User avatar
Villeroy
Volunteer
 
Posts: 29580
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 6 guests