Libre Base How to change FixedText control size at runtime

How do you get the size of a fixed text control at runtime?
How do you change the size of a fixed text control at runtime?


FixedText control? Educated guess is a Label.

Look at this-> Resizing Form Edit Boxes to their size content

Yes that worked thanks. I can change the size of the added label but it seems to be anchored incorrectly and I cannot find a way to change the anchor of a label.
The label seems to be stuck at a certain column and no matter what I put as an x position it stays in the same place.
I found this answer for anchoring here
but that can’t work since the shape objects anchor property is read only.

objShape = ThisComponent.createInstance("") objShape.setName(strName) objShape.setControl(objBttn) objSheet.Drawpage.add(objShape) objShape.Anchor = objCell objShape.setSize(objCell.Size) objShape.setPosition(objCell.Position)

Seems you have tagged your question incorrectly. It is marked as Base - that is the database module. Now you seem to be talking about Calc. Is this correct?
If so more clarity is needed as to just what you may be doing as this was not part of the original question.

No, this is on a Base Form.
I want to add and position a label on a base form but as I said the label won’t go where it is supposed to go.
When after I programatically add the label it appears in the wrong place and when I edit the form the label is stuck in its column. I change the anchoring manually and I can move the control as normal.
I would like to change the anchoring programatically because I think that is why it isn’t positioning properly.

I just brought that code over from the calc forum as it was the only code I could find that even talks about anchoring.

This made it appear to be Calc.

Can easily adjust y-axis but x-axis goes no where. Used a Grid control in my test. Possible bug?
May try more tomorrow.

Thank you for looking at it.

As a note, can easily change in a Calc form:
AddDeleteButtonControl.ods (10.4 KB)
Please excuse the code. Older test file.
This may be of note also → enum TextContentAnchorType

  Shape.AnchorType =

You have cross posted this here → Add control to Libre Base form at runtime

While there is nothing wrong with cross posting, it is rude to do so without making note of it in each post! Duplicate effort may occur without the other knowing.

If all this (according to the other post) is due to a lack of a grid control, then do what I did - use a text table.

See → Looking to create grid (not table) control on Base form

It is always best to explain what you are trying to accomplish. You placed more in the other post than here.

I wouldn’t call it a cross post since the question I asked here was very specific and different from that question.
That you have discovered a relationship to the other question is irrelevant but if you feel I am being rude then I apologize.
I could ask this question as a new topic over there, but I liked my chances here better.
I have tried numerous controls with the same result.
I have tried working around it by getting the control from the model and using setPosSize() however that is also ignored.
I am going to file this as a bug specific to Libre Base.
Bug report can be found here

Looks the same to me,


Your sample there seems not to have been tested. I get errors. There are many in that sample!

As I look further at your sample (corrected some code), it may be that setting the cursor may be the answer.
And what about the Text Table suggestion?

How do you add controls to Base forms at runtime?

Is not the same question as

How do you get the size of a fixed text control at runtime?
How do you change the size of a fixed text control at runtime?

I accidentally left a bunch of testing code in the bug report attachment and I neglected to explain how to run the base file.
I removed the superfluous code and added instructions as to how to run it.
Open the base file and double click “testform”. Then press the button.

Not in my view of all stated. Done here.

Fair enough.
But note that under those loose standards, all of my questions are the same.

Just for the sake of having an answer (code just thrown together - needs cleaning):

InsertControl.odb (13.3 KB)

Still issues. Adding a control in real time when the form is closed it is gone. To retain it mus be added when editing the form.


In the sample posted on Bugzilla, after creating an instance of the shape, the anchor can be changed:

	sub AddControl(byref controlName as string, byref label as string, byref oDocument as object, byref oDrawPage as object)  as object 
		dim oControlShape as object 
		dim aPoint as object, aSize as object, oModel as object
	 	oControlShape = oDocument.createInstance("")
  oControlShape.AnchorType =

Then the control positions correctly.

Thank you. That seems to work.
I changed the original bug report to ‘not a bug’ as I now don’t think it is one.
I have added an enhancement request regarding this.
I believe that it will be the rarest of rare situations wherein the programmer would want the anchor type of a dynamically added control to be ‘As Character’. Therefore the default should be ‘At Page’ (on a base from at least) (imo).