Bonjour,
Alexandre MILLOT a écrit le 08/07/04 11:17 :
Bonjour,
J'ai ecrit une macro qui permet d'inserer un champ utilisateur à la
position courante su curseur, or lorsque celui ci est dans un tableau
j'ai un message d'erreur. Ci-Joint le code que j'utilise, merci
d'avance.
Étant intéressé par la création de champs de formulaire par macro, j'ai
regardé, mais je n'arrive pas à faire fonctionner ta macro même en
dehors d'un tableau.
Autrement, j'ai trouvé sur OOoForum une macro qui permet de créer un
bouton dans Calc.
Si ça peu aider....
Bonne chance
Tony
----------------------------------------------------------------------
Sub formsincalc()
Dim aPos as new com.sun.star.awt.Point
Dim aSize as new com.sun.star.awt.Size
odoc = thisComponent
'create a form..
oform = odoc.createInstance( "com.sun.star.form.component.Form" )
'get the drawpage of the first sheet and insert the form there..
osheet = odoc.getSheets().getByIndex(0)
odrawpage = osheet.getDrawPage()
odrawpage.Forms.insertByName("MyForm", oform)
'now create a Shape that will visualize the Buttonmodel
button_shape = odoc.createInstance("com.sun.star.drawing.ControlShape")
'Position of it..
aPos.X = 5000
aPos.Y = 7000
button_shape.Position = aPos
'Size of it..
aSize.Width = 3000
aSize.Height = 1600
button_shape.Size = aSize
'now create a simple button for it..
button_model =
odoc.createInstance("com.sun.star.form.component.CommandButton")
button_model.Name = "CmdButton"
button_model.Label = "Click here"
'now connect model and shape with each other
button_shape.Control = button_model
'now insert it into the form..
odrawpage.Forms.getByName("MyForm").insertByIndex(0, button_model)
'now add it to the drawpage so that it becomes visible..
odrawpage.add(button_shape)
End Sub