Roberto Birago ha scritto:
Gli eventi predefiniti su OO riguardano genericamente un documento.
Il mio problema è quello di intercettare come evento la variazione di una cella di Calc (per eseguire determinati controlli). Già nella sua natura la variazione di una cella è gestita da Calc come un evento. Come poter intercettare questo evento e collegarlo ad una funzione StarBasic?

Grazie

Roberto Birago

How to Use a Calc Macro to Monitor Cell Contents

http://computer-programming-tutorials.suite101.com/article.cfm/how_to_work_with_user_selections_in_calc_macros

Non so se e' una cosa del genere che cerchi, non l'ho provata.

ciao
Beppe


Option Explicit 'Enforce variable definition

Global oCell(0)
Global oListener

rem Next a subroutine is needed - this subroutine will add cells to the array as necessary, and then add a listener to the cell:
Sub add_cell_listener (cell_id As String)
Dim oSheet
Dim i As Integer
i = ubound(oCell) + 1
Redim Preserve oCell(i)
oSheet = thisComponent.Sheets("Sheet1")
oCell(i) = oSheet.getCellRangeByName(cell_id)
oListener = CreateUnoListener( "CELL_", _
"com.sun.star.chart.XChartDataChangeEventListener" )
oCell(i).addChartDataChangeEventListener(oListener)
End Sub

rem It's worth noting that there is not a listener specifically for cells - what's actually being used here is the OpenOffice functionality for updating charts.
rem The Data Changed Subroutine

rem When the listener is defined the prefix for the 'data changed' subroutine is also defined (in this case the prefix is CELL_), and the suffix must be chartDataChanged:
Sub CELL_chartDataChanged

rem The contents of each of the monitored cells can now be processed:
Dim i As Integer
for i = 1 to ubound(oCell)
msgbox "Cell value = " & oCell(i).Value & chr(10) _
& "Cell String = " & oCell(i).String & chr(10) _
& "Cell Formula = " & oCell(i).Formula
next i
End Sub

rem Starting the Listeners

rem The listeners are not assigned to the cells automatically - for that a final subroutine is required:
Sub Main
add_cell_listener "A1"
add_cell_listener "A2"
End Sub

--
le nuvole non hanno regole,
perchè non hanno mai rinunciato
alla libertà di sognare.



---------------------------------------------------------------------
To unsubscribe, e-mail: utenti-unsubscr...@it.openoffice.org
For additional commands, e-mail: utenti-h...@it.openoffice.org

Reply via email to