| View previous topic :: View next topic |
| Author |
Message |
Salomon Guest
|
Posted: Thu Mar 27, 2003 1:39 pm Post subject: Goal Seek with OpenOffice BASIC |
|
|
Hi,
I'm writing a macro that will prompt the user for some information and then use the Goal Seek function (seekGoal) to reach a certain value. The problem is that although I was able to find the function itself, I am not getting any results from the function call. What is the correct way to call the function? Do I have to explicityly load any libraries?
Thanks |
|
| Back to top |
|
 |
paolo General User

Joined: 02 Mar 2003 Posts: 31 Location: Italy
|
Posted: Thu Mar 27, 2003 3:55 pm Post subject: Re: Goal Seek with OpenOffice BASIC |
|
|
Hi Salomon
The seekGoal method returns a UNO structure:
com.sun.star.sheet.GoalResult
This structure has two properties:
Divergence (a double)
Result (a double)
Please, see the following example, where the A1 cell of the sheet 1 should contains the formula and the cell B1 should be a parameter in this formula:
| Code: |
REM ***** BASIC *****
Sub TestGoalSeek
Dim oDoc As Object
Dim oFormulaAddress As New com.sun.star.table.CellAddress
Dim oVariableAddress As New com.sun.star.table.CellAddress
Dim sGoal As String
Dim oResult As Object
oDoc = ThisComponent
'the A1 cell in the sheet1
With oFormulaAddress
.Sheet = 0
.Column = 0
.Row = 0
End With
'the B1 cell in the sheet1
With oVariableAddress
.Sheet = 0
.Column = 1
.Row = 0
End With
'the goal value
sGoal = "81"
oResult = oDoc.seekGoal(oFormulaAddress, oVariableAddress, sGoal)
print oResult.Result
print oResult.Divergence
End Sub
|
hope this helps
Ciao
Paolo Mantovani |
|
| Back to top |
|
 |
salomon General User


Joined: 27 Mar 2003 Posts: 13 Location: Brasilia, DF, Brazil
|
Posted: Fri Mar 28, 2003 7:04 am Post subject: Re: Goal Seek with OpenOffice BASIC |
|
|
Paolo,
Thanks a lot. It worked great. BTW, is there a more high level doc where one can find the OpenOffice BASIC documentation with information such as the one you gave me?
Best regards, |
|
| Back to top |
|
 |
paolo General User

Joined: 02 Mar 2003 Posts: 31 Location: Italy
|
|
| Back to top |
|
 |
josir General User


Joined: 25 Jul 2003 Posts: 19 Location: Rio de Janeiro, Brasil
|
Posted: Tue Sep 23, 2003 10:17 am Post subject: Solver |
|
|
Hi Paolo,
do you know any library, algorithm or source code that implements the Solver (found in Excel) on OpenOffice ?
Thanks in advance,
Josir |
|
| Back to top |
|
 |
a-bo.net Newbie

Joined: 27 Feb 2010 Posts: 1 Location: Bozen-Bolzano Italy
|
Posted: Sun Feb 28, 2010 12:04 am Post subject: |
|
|
how can I convert excel macros in oO macros? Is there somebody in Italy I can phone?
Bernhard |
|
| Back to top |
|
 |
|