They all have a macro on the mouse button released event.
In this Sub I try to retrieve the name of the calling push button (with code borrowed from Pitonyak).
For certain shapes that are passed through for this, there appears to be no getControl method.
I have already tried in vain to get around this problem with the 'On Error'.
Question: How can I determine whether a getControl method exists?
Attached is the Sub.
Thanks in advance for your suggestions on this.
Code: Select all
Sub ButtonCall(x)
Dim oButton ' Button that was used to call the handler.
Dim oModel ' The model for the button.
Dim oShape ' The underlying button shape.
Dim oControl
Dim I, J As Long ' Generic index variable.
Dim bFound As Boolean ' True after find the matching shape.
Dim Naam as String
' First, get the button used to call this routine. Save the button's model.
oButton = x.Source
oModel = oButton.getModel()
Naam = "Fout"
' Iterate through the sheets en hun controls
I = ThisComponent.getDrawPages().getCount()
bFound = False
Do While (i > 0 AND NOT bFound)
I = I - 1
oShape = ThisComponent.getDrawPages().getByIndex(I)
J = oShape.Count
Do While (J > 0 AND NOT bFound)
J = J - 1
On Error GoTo SkipIt
'ErrorLog("Buttoncall: I=" + I + ", J=" + J, FALSE)
oControl = oShape.getByIndex(J).getControl() '<<<<<<<<<<<<<<<<<<<<<<<<<<<
Naam = oControl.Name
bFound = EqualUNOObjects(oControl, oModel)
SkipIt:
Loop
Loop
If bFound Then
' I = ButtonDispatcher(Naam)
Msgbox Naam
Else
ErrorLog("Buttoncall opgeroepen, maar geen naam van de drukknop gevonden")
End If
End Sub