[SOLVED] Libreoffice Base: How to use a macro to write to cells of a table drawn on a form?

In Libreoffice base I have a very simple form as an example with a button and a table drawn on the form (not a database table nor a Table Control field from the “Form” menu but the one you can draw on the form by using the menu “Table” → “Insert Table…” in the design mode of the form).

I would like to write some text into that table (e.g. in the first cell “hello” and in the second “world”) when clicking the button.

When I click on “table properties…” it displays under the “Table” the Name “tblOverview” (which I entered when drawing the table). Accessing this via the following yields the error that the field “tblOverview” cannot be found:

oForm = ThisComponent.Drawpage.Forms.getByName(“MainForm”)
oTab= oForm.getByName(“tblOverview”)

Thank you very much in advance for any insights to this

Please, always add an example file, so you don’t force anyone to help you from scratch.

The tables, like the one you used, are not part of the form, but of the document.

CARE: You must run this macro from your open form.

	doc = ThisComponent
	table = doc.TextTables.getByIndex(0)
	table.getCellByName("A1").String = "Hello"
	table.getCellByName("B1").String = "World"


works like a charm! Thank you.
Will do the sample doc in the future, thanks for the hint.

FYI: Instead of getByIndex(0) I use now getByName(“tblOverview”)