OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Goal Seek with OpenOffice BASIC

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
Salomon
Guest





PostPosted: Thu Mar 27, 2003 1:39 pm    Post subject: Goal Seek with OpenOffice BASIC Reply with quote

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
General User


Joined: 02 Mar 2003
Posts: 31
Location: Italy

PostPosted: Thu Mar 27, 2003 3:55 pm    Post subject: Re: Goal Seek with OpenOffice BASIC Reply with quote

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
View user's profile Send private message
salomon
General User
General User


Joined: 27 Mar 2003
Posts: 13
Location: Brasilia, DF, Brazil

PostPosted: Fri Mar 28, 2003 7:04 am    Post subject: Re: Goal Seek with OpenOffice BASIC Reply with quote

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
View user's profile Send private message Visit poster's website
paolo
General User
General User


Joined: 02 Mar 2003
Posts: 31
Location: Italy

PostPosted: Fri Mar 28, 2003 3:11 pm    Post subject: Re: Goal Seek with OpenOffice BASIC Reply with quote

Salomon,

A good start point is here:
http://website.openoffice.org/developer/

Don't forget to download the Tutorial:
http://api.openoffice.org/basic/man/tutorial/tutorial.pdf

and the SDK
http://www.openoffice.org/dev_docs/source/sdk/

that contains the OpenOffice.org API Reference (IDL documentation) and the Developer's Guide.

Ciao
Paolo Mantovani
Back to top
View user's profile Send private message
josir
General User
General User


Joined: 25 Jul 2003
Posts: 19
Location: Rio de Janeiro, Brasil

PostPosted: Tue Sep 23, 2003 10:17 am    Post subject: Solver Reply with quote

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
View user's profile Send private message Send e-mail
a-bo.net
Newbie
Newbie


Joined: 27 Feb 2010
Posts: 1
Location: Bozen-Bolzano Italy

PostPosted: Sun Feb 28, 2010 12:04 am    Post subject: Reply with quote

how can I convert excel macros in oO macros? Is there somebody in Italy I can phone?
Bernhard
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group