Passing cell to function in macro | seek goal function wrapp

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
hever
Posts: 2
Joined: Tue Jun 10, 2008 9:38 am

Passing cell to function in macro | seek goal function wrapp

Post by hever »

Hi,

by now I'm sure that there is no seek goal function in OO Calc.
I found no really useful Extensions, Macros, whatever.
(A bit strage, because there are a lot of extensions and makros where I'am not really sure if they are as needed as a seekgoal)

So I tried to write myself a Wrapper to wrap the seekgoal method from the API.

My Problem is that I don't know how I can pass a Cell to the function so that I can use it in the seekgoal method or access the corrdinates of a cell passed as argument.

There is a lot in the Inet about accessing cells by their name or coordinates but I don't like such statically solutions.

For example:
http://www.oooforum.org/forum/viewtopic.phtml?t=598

So please help and tell me if passing a cell to a function is possible and if yes, how?

Or it can be that there is somewhere out there already an existing wrapper...
OOo 2.4.X on Debian
User avatar
Villeroy
Volunteer
Posts: 31363
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Passing cell to function in macro | seek goal function wrapp

Post by Villeroy »

All function arguments are passed as values rather than object references. This is the same limitation in add-ins and Basic functions. IMHO there is nothing we can do about this except rewriting the core of the Calc component.
As a workaround you may write a wizard to let the user point specific ranges or use something like this http://user.services.openoffice.org/en/ ... =21&t=2762 (passing "coordinates" sheet, row, column)
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
hever
Posts: 2
Joined: Tue Jun 10, 2008 9:38 am

Re: Passing cell to function in macro | seek goal function wrapp

Post by hever »

Hello,

thanks for your reply.

I thought about passing the coordinates to the function but before this, I looked for better solutions.
But it seems as you say there are no.... so I will pass the coordinates.

It seems a bit incomprehensible to others to use this function if I share it.

Anyway, thanks for you help...
OOo 2.4.X on Debian
User avatar
rosajo
Posts: 3
Joined: Sat Jun 14, 2008 4:10 pm

Re: Passing cell to function in macro | seek goal function wrapp

Post by rosajo »

Hi hever,

Some time ago I had the same issue and i took over 3 weeks finding out how to resolve an issue like yours.

This is how i resolved:

1) created a function like this:

Code: Select all

function fBase ( tCell as com.sun.star.table.CellRange )
<....>
end function
2) on the sheet Cell I called the function with the cell as a range. Like this:
=FBASE(A3:A3)


Inside the funtion i had to treat the logic i needed.

Hope this helps.
Regards - JR
OOo 2.3.X on Mac OSx Leopard + Ms Windows
Post Reply