Programmatically created nested tables

  • Could you provide a source code or link to that?
    How to insert one table into cell of another?
    I've tried different approaches but got two independent tables instead.
    wptblAllowNestedTables attribute has been applied to parent table.

  • Thank you, the code really works.

    The only problem remains, I can't get back to parent table to insert another embedded table into other cell.
    TableColNumber, TableRowNumber are apply now to newly inserted table but not to top level one.

    // create parent 2x2 table
    tbl:=TableAdd(2, 2, [wptblActivateBorders, wptblPlaceCursorInLastCell]);

    // set cell of the parent table
    TableColNumber:= 0; TableRowNumber:= 0;

    // insert a first embedded table
    TableAdd(2,2, [wptblActivateBorders, wptblAllowNestedTables, wptblPlaceCursorInLastCell]);

    // set another cell of the parent table
    TableColNumber:= 1; TableRowNumber:= 0;

    // insert a second embedded table
    TableAdd(2,2, [wptblActivateBorders, wptblAllowNestedTables, wptblPlaceCursorInLastCell]);

    The last statement inserts a third table into inserted one, not into a top-level table.
    How to get a handle of the top-level (parent) table to manipulate with current row and column for that?

    I've tried to set a current cell of the parent by inputting a text to target cell, but it doesn't work, i.e. doesn't change a current paragraph.

    tbl.Rows[0].Cols[1].SetText('right table cell');

  • In my case wp.CPMoveNext() helped but it is not a general solution.

    The question is:
    How to navigate between the tables and select a specific cell in specific table?

    Can I get something similar to table handle and thereafter refer to it if I need apply, for instance, TableColNumber, TableRowNumber to any table in the document, not just to laste created/focused?

    P.S.
    It would be nice to have wptblPlaceCursorInFirstCell option to complement wptblPlaceCursorInLastCell flag.