von Tictac » Mo, 15.08.2011 11:23
Hallo Komma4,
Da ist ja mein Problem. Ich versuch das schon das Wochenende mit xRay und Andrew Pitoniak.
Anbei mal mein Beispielcode:
Code: Alles auswählen
Sub Button
Dim btnControl as Object
Dim btnShape as Object
Dim oEvents(0) As New com.sun.star.script.ScriptEventDescriptor
'buttonContolsAnlegen
btnControl = CreateUnoService("com.sun.star.form.component.CommandButton")
btnControl.Label = "Test"
btnControl.Name = "Test"
'EventListenerErstellen
oEvents(0).ListenerType = "XActionListener"
oEvents(0).EventMethod = "actionPerformed"
oEvents(0).AddListenerParam = ""
oEvents(0).ScriptType = "StarBasic"
oEvents(0).ScriptCode = "document:Standard.ButtonNeu.btnTestMethode"
'EventListenerHinzufügen
btnControl.addEventListener(oEvents(0))
'Button auf Shape legen und ausgeben
btnShape = ThisComponent.CreateInstance("com.sun.star.drawing.ControlShape")
btnShape.Size = createSize(2200,800)'Größe Kontrollfeld 2,2x0,8 cm
btnShape.Position = createPoint(1500, 3000) 'Position Kontrollfeld bei x=1,5 cm, y=3cm
btnShape.control = btnControl
ThisComponent.Sheets(0).DrawPage.Add(btnShape)
End Sub
Allerdings bekomme ich beim EventlistenerHinzufügen einen Fehler (Illegal Argument: cannot coerce argument type during corereflection call!)
Ich habe keine Ahnung was ich da falsch mache und damit ist alles andere auch nicht hilfreich.
Hallo Komma4,
Da ist ja mein Problem. Ich versuch das schon das Wochenende mit xRay und Andrew Pitoniak.
Anbei mal mein Beispielcode:
[code]Sub Button
Dim btnControl as Object
Dim btnShape as Object
Dim oEvents(0) As New com.sun.star.script.ScriptEventDescriptor
'buttonContolsAnlegen
btnControl = CreateUnoService("com.sun.star.form.component.CommandButton")
btnControl.Label = "Test"
btnControl.Name = "Test"
'EventListenerErstellen
oEvents(0).ListenerType = "XActionListener"
oEvents(0).EventMethod = "actionPerformed"
oEvents(0).AddListenerParam = ""
oEvents(0).ScriptType = "StarBasic"
oEvents(0).ScriptCode = "document:Standard.ButtonNeu.btnTestMethode"
'EventListenerHinzufügen
btnControl.addEventListener(oEvents(0))
'Button auf Shape legen und ausgeben
btnShape = ThisComponent.CreateInstance("com.sun.star.drawing.ControlShape")
btnShape.Size = createSize(2200,800)'Größe Kontrollfeld 2,2x0,8 cm
btnShape.Position = createPoint(1500, 3000) 'Position Kontrollfeld bei x=1,5 cm, y=3cm
btnShape.control = btnControl
ThisComponent.Sheets(0).DrawPage.Add(btnShape)
End Sub[/code]
Allerdings bekomme ich beim EventlistenerHinzufügen einen Fehler (Illegal Argument: cannot coerce argument type during corereflection call!)
Ich habe keine Ahnung was ich da falsch mache und damit ist alles andere auch nicht hilfreich.