With BASIC how do you select the next table?

I am very new to using the BASIC macros in Libre Office.

I am using a template doc with text and pre-defined tables.

I can insert text where I want with Cursor.gotoNextParagraph(False),
Cursor.gotoEndOfSentence(False) etc.

My difficulties are with tables, how do you select the next table?

Cell = Table.getCellByName(“B2”)
Cell.String = " Some Text "

Many interesting methods of work with text tables can be found in this book by Andrew Pitonyak

Sub workWithTextTables
Dim oDoc As Variant
Dim oTextTables As Variant
Dim oTable As Variant
Dim oCell As Variant
Dim i&
	oDoc = ThisComponent
	oTextTables = oDoc.getTextTables()
	For i = 0 To oTextTables.getCount()
		oTable = oTextTables.getByIndex(i)
           ... do something ...
	Next i
REM // or by name
	oTable = oTextTables.getByName("tbl_1")
oTable = oTextTables.getByName("tbl_2")
oTable = oTextTables.getByName("myNextTable") etc...
REM // get cell by Column/nRow
	oCell = oTable.getCellByPosition(0, 1)
REM // or by name
	oCell = oTable.getCellByName("A2")
	oCell.setString(" Some Text ")
End Sub

Thanks for that.

Will be studying it over the next few days.

Hi @Kevin.kd – Did @JohnSUN’s answer help you out? If it solved your problem, please mark it as correct. If you still have additional questions on this topic, please let us know so we can help you further.