Macros/Base/ba003
TDF LibreOffice Document Liberation Project Community Blogs Weblate Nextcloud Redmine Ask LibreOffice Donate
Description
Add control (TextBox) in runtime a form.
Import, you need execute this code from a form, always.
Sub create_text_box()
Dim pos As New com.sun.star.awt.Point
Dim size As New com.sun.star.awt.Size
doc = ThisComponent
draw_page = doc.DrawPage
form = draw_page.Forms.getByName("MainForm")
new_text_box = doc.createInstance("com.sun.star.drawing.ControlShape")
pos.X = 1000
pos.Y = 5000
new_text_box.setPosition(pos)
size.Width = 10000
size.Height = 800
new_text_box.setSize(size)
text_box_model = doc.createInstance("com.sun.star.form.component.TextField")
text_box_model.Name = "txt_new_text_box"
new_text_box.Control = text_box_model
form.insertByIndex(0, text_box_model)
draw_page.add(new_text_box)
End Sub
#
# tbd: To be done
#
Return to Macros/Base