von delta9 » Mo, 20.08.2012 13:39
Danke, aufgrund des Stichwortes habe ich nun folgenden Listener mir zusammengeklaut, ohne richtig zu verstehen wie er funktioniert. Aber er funktioniert! Jedoch ich möchte immer ein Makro, wenn ich von einer bestimmten Tabelle WEGGEHE.
Das könnte ich sicher mit irgendwelchen Merker-Variablen erkennen, aber vielleicht gibt es noch eine elegantere Methode,
Z.B. ein Listener der nicht reagiert, wenn man auf dem neuen Blatt angekommen ist, sondern wenn man vom alten geht (und dann dessen Name unmittelbar abfragen kann?
Code: Alles auswählen
Global oListener As Variant
Global oView As Variant
global oListener
Sub add_Listener
Dim oDoc
Dim oVIEW
' get the model
oDoc = thisComponent
' get the controller
oView = oDoc.getCurrentController()
' create the listener
oListener = CreateUnoListener ("XList_", "com.sun.star.sheet.XActivationEventListener")
' add the listener to controller
oView.addActivationEventListener (oListener)
' msgBox "XActivationEventListener added"
End Sub
Sub remove_Listener
' remove the listener from controller
oView.removeActivationEventListener (oListener)
msgBox "XActivationEventListener removed"
End Sub
'______________________________________________________
' Interface com.sun.star.sheet.XActivationEventListener
'______________________________________________________
' method activeSpreadsheetChanged()
Sub XList_activeSpreadsheetChanged ( oEvento )
dim oSheet
dim sSheetName
' get the event object
oSheet = oEvento.ActiveSheet
sSheetName = oSheet.getName()
if sSheetName = NameWirtschaftsblatt then
msgBox (sSheetName, 176, "Active Sheet")
end if
End Sub
'_________________________________________________________________
' method disposing() of interface com.sun.star.lang.XEventListener
' !! It isn't necessary !!
Sub XList_disposing ( oEvt )
' nothing to do
End Sub
Danke, aufgrund des Stichwortes habe ich nun folgenden Listener mir zusammengeklaut, ohne richtig zu verstehen wie er funktioniert. Aber er funktioniert! Jedoch ich möchte immer ein Makro, wenn ich von einer bestimmten Tabelle WEGGEHE.
Das könnte ich sicher mit irgendwelchen Merker-Variablen erkennen, aber vielleicht gibt es noch eine elegantere Methode,
Z.B. ein Listener der nicht reagiert, wenn man auf dem neuen Blatt angekommen ist, sondern wenn man vom alten geht (und dann dessen Name unmittelbar abfragen kann?
[code]Global oListener As Variant
Global oView As Variant
global oListener
Sub add_Listener
Dim oDoc
Dim oVIEW
' get the model
oDoc = thisComponent
' get the controller
oView = oDoc.getCurrentController()
' create the listener
oListener = CreateUnoListener ("XList_", "com.sun.star.sheet.XActivationEventListener")
' add the listener to controller
oView.addActivationEventListener (oListener)
' msgBox "XActivationEventListener added"
End Sub
Sub remove_Listener
' remove the listener from controller
oView.removeActivationEventListener (oListener)
msgBox "XActivationEventListener removed"
End Sub
'______________________________________________________
' Interface com.sun.star.sheet.XActivationEventListener
'______________________________________________________
' method activeSpreadsheetChanged()
Sub XList_activeSpreadsheetChanged ( oEvento )
dim oSheet
dim sSheetName
' get the event object
oSheet = oEvento.ActiveSheet
sSheetName = oSheet.getName()
if sSheetName = NameWirtschaftsblatt then
msgBox (sSheetName, 176, "Active Sheet")
end if
End Sub
'_________________________________________________________________
' method disposing() of interface com.sun.star.lang.XEventListener
' !! It isn't necessary !!
Sub XList_disposing ( oEvt )
' nothing to do
End Sub
[/code]