Re: PushButton per Makro erstellen?
Verfasst: Do, 03.02.2011 20:39
Bin mir ziemlich sicher, dass die Antwort auch zu dieser Frage bei Andrew in seinem Makro-Dokument zu finden ist.
Viel Erfolg!
Viel Erfolg!
deutsches Forum rund um Apache OpenOffice und LibreOffice
https://oooforum.de/
Code: Alles auswählen
sub addButton
oSheet = thiscomponent.sheets(0)
oPage = oSheet.drawpage
Dim aPoint As New com.sun.star.awt.Point
Dim aSize As New com.sun.star.awt.Size
aPoint.x = 10000
aPoint.y = 10000
aSize.Width = 10000
aSize.Height = 1600
btn = thiscomponent.createInstance("com.sun.star.drawing.ControlShape")
oControlModel = thiscomponent.createInstance( "com.sun.star.form.component.CommandButton" )
btn.control = oControlModel
btn.Size = aSize
btn.Position = aPoint
btn.Control.Label = "Klick mich!"
oPage.add(btn)
oForm = btn.control.parent
nIndex = oForm.Count-1 'Der Button wurde soeben eingefügt, deshalb ist es sehr wahrscheinlich, dass er das letzte Element der Controls-Liste der Form ist.
Dim oEvent as new com.sun.star.script.ScriptEventDescriptor
oEvent.ListenerType = "com.sun.star.awt.XActionListener"
oEvent.EventMethod = "actionPerformed"
oEvent.ScriptType = "StarBasic"
oEvent.ScriptCode = "vnd.sun.star.script:Standard.Module1.test"
oForm.registerScriptEvent(nIndex, oEvent)
thiscomponent.currentcontroller.setformdesignmode(false)
end sub
sub test(oEvent)
xray oEvent
end sub