How could I insert a text table inside a text table by macro?

For a report (Base → Writer) I have to create a table, which contains one table in first column and another table in second column.
I know how to create a table by

oTable = ThisComponent.createInstance("com.sun.star.text.TextTable")
oTable.initialize(2, 3)
oInsertPoint = ThisComponent.Text.getEnd()
oInsertPoint.getText().insertTextContent(oInsertPoint, oTable, False)

I have set the cursor to the field A1 in this table by ThisComponent.CurrentController.select(oTable) but I don’t find a way to insert a new table in this table. Method insertTextContent isn’t available here.

Have tried it with macro recording. Could get it work with dispatcher, but might be there is a direct solution?

sub t_in_t
  oTable = ThisComponent.createInstance("com.sun.star.text.TextTable")
  oTable.initialize(2, 3)
  ThisComponent.getText().insertTextContent(ThisComponent.getText().getEnd(), oTable, False)

  cell = oTable.getCellByPosition(0, 0)
  oTable2 = ThisComponent.createInstance("com.sun.star.text.TextTable")
  oTable2.initialize(2, 3)
  cell.insertTextContent(cell, oTable2, True)
end sub
3 Likes

Thanks a lot, Mike!