Hi,
I use easy examples on ’ how to listen event on cel modified’.
I just put an MsgBox in the sub called but the issue is the next :
When i load the file and modify a cell, the sub is correctly called and show me the msgbox, but if i modify another cell (or the same), the sub is called twice … and if i modify again another cell (or the same) the sub is called three times and so on and so on …
So i think that something is buffered somewhere … but what and where i don t know …
Is there a way to empty the listener or something else ?
Thx anymay for all the responses u can give.
Edited for adding code :
global PysClass as Object
global PysListener as Object
sub main
PysListenersAdd
end sub
Sub PysListenersAdd
PysClass= thisComponent.Sheets.getByName("Effectifs")
PysListener = CreateUnoListener( "Pys_", "com.sun.star.util.XModifyListener" )
PysClass.AddModifyListener(PysListener)
End Sub
Sub PysListenersRemove
PysClass.RemoveModifyListener(PysListener)
End Sub
Sub Pys_Modified(oEvent)
PysListenersRemove()
MarkForChange(oEvent)
PysListenersAdd()
end sub
Sub Pys_Disposing
End Sub
Sub MarkForChange(evt)
Dim laCellule As Object, CelluleActive As Object, dispatcher as object, document as object
dim en_cours as integer
laCellule = evt.Source
'MsgBox ecouteurCellule.DBG_Properties
'MsgBox ecouteurCellule.DBG_methods
' MsgBox("Cellule : " & laCellule.AbsoluteName & chr(13) & "Valeur : " & laCellule.value & chr(13) & "Texte : " & laCellule.string & chr(13) & "Formule : " & laCellule.FormulaLocal)
CelluleActive = ThisComponent.getCurrentController.selection
if CelluleActive.supportsService("com.sun.star.sheet.SheetCell") then
if CelluleActive.string = "" then
en_cours = CelluleActive.CellAddress.row
oLigne = oFeuille.getRows.getByIndex(en_cours)
thisComponent.currentController.select(oLigne)
oFeuille.getRows.removeByIndex(en_cours,1)
redim laCellule
Exit Sub
end if
if CelluleActive.string <> "" then
MsgBox "New !!!"
redim laCellule
Exit Sub
end if
end if
End Sub