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

cell listener

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


Joined: 23 Dec 2007
Posts: 5

PostPosted: Thu Dec 27, 2007 12:53 pm    Post subject: cell listener Reply with quote

I've got a CellRange that i want to 'listen', I managed to turn on the listener but i just cant turn it off... I neet to remove the listener because I need to change the Values in that cellrange with macro...
I've tried everything but i just cant remove the listener on range of cells...

Here is the code:
Code:

Sub EventListenerOn
  oScalcDocument=ThisComponent
  oSheet = oScalcDocument.Sheets(0)
  oGroup=oSheet.getCellRangeByName("B15:B29")
  oListener = createUnoListener("OOO_","com.sun.star.chart.XChartDataChangeEventListener")
  oGroup.addChartDataChangeEventListener(oListener)
   
End Sub

Sub EventListenerOff
  oScalcDocument=ThisComponent
  oSheet = oScalcDocument.Sheets(0)
  oGroup=oSheet.getCellRangeByName("B15:B29")
  oListener    = createUnoListener("OOO_", "com.sun.star.chart.XChartDataChangeEventListener")
  msgbox "listener off"
  oGroup.removeChartDataChangeEventListener(oListener)
End Sub 

Sub OOO_chartDataChanged
   
   EventListenerOff
   msgbox "changed"
   some_sub
   EventListenerOn
End Sub
Back to top
View user's profile Send private message
Boskarin
General User
General User


Joined: 23 Dec 2007
Posts: 5

PostPosted: Thu Dec 27, 2007 2:42 pm    Post subject: Reply with quote

I think that I solved it, I'll see Smile
I declared oGroup variable as Global, and for now it works...
Back to top
View user's profile Send private message
arivas_2005
Power User
Power User


Joined: 10 Oct 2006
Posts: 98
Location: El Salvador CentroAm

PostPosted: Tue Jan 01, 2008 2:18 pm    Post subject: Reply with quote

greetings

Taking advantage of the subject

It would be possible to run a macro
according to the value of a cell
Using a function of spreadsheet (like a customized function)
For example: if B4=5 then to call the macro "OO_CellDataChanged"
(the function could have another name instead of if)

Code:
Sub OO_CellDataChanged
   msgbox "changed to 4"
End Sub


'-----------
I found the ideas to resover here
http://www.oooforum.org/forum/viewtopic.phtml?t=9673

Code:
Function isdouble(ByVal pNumber As Double) As Double)
    '
    if pNumber=4 then call  OO_CellDataChanged
End Function


on the sheet, in a cell:
=isdouble(B5) 'The Function is ejecuted
' enter numbers in B5, for example 2 or 3
Thanks again!
Back to top
View user's profile Send private message
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