| View previous topic :: View next topic |
| Author |
Message |
Boskarin General User

Joined: 23 Dec 2007 Posts: 5
|
Posted: Thu Dec 27, 2007 12:53 pm Post subject: cell listener |
|
|
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 |
|
 |
Boskarin General User

Joined: 23 Dec 2007 Posts: 5
|
Posted: Thu Dec 27, 2007 2:42 pm Post subject: |
|
|
I think that I solved it, I'll see
I declared oGroup variable as Global, and for now it works... |
|
| Back to top |
|
 |
arivas_2005 Power User

Joined: 10 Oct 2006 Posts: 98 Location: El Salvador CentroAm
|
Posted: Tue Jan 01, 2008 2:18 pm Post subject: |
|
|
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 |
|
 |
|