Skip to main content
Community Expert
January 8, 2026
Answered

How to update a table format with a script

  • January 8, 2026
  • 1 reply
  • 106 views

Hi,
I have an ExtendScript script which changes the language of all paragraphs.
It also changes the language of those paragraphs which are in tables.
Now I also want to change the table formats so that they contain the paragraphs with the changed language and not with the old language.
However, my script deletes somehow all table formats!
What I do:
For each table format add a new table.
Then the language of all paragraph formats is changed and imported into the file.
Now update the table formats.

for (var li = 0; li < faArrayTables.length; li += 1) // faArrayTables is an array with all these new tables.
{
	loTable = faArrayTables [li];
	laProps = loTable.GetProps ();
	loTblFmt = foDoc.GetNamedObject (Constants.FO_TblFmt, loTable.TblTag);
	loTblFmt.SetProps (laProps);
}

loTblFmt.SetProps deletes all table formats!
I guess that I cannot just transfer the properties of an existing table to a table format. And this deletes the table.
How can I update the table format of a table?
Best regards, Winfried

    Correct answer Winfried Reng

    @Klaus Göbel has helped me to get on track.

    Here is the correct loop:

    for (var li = 0; li < faArrayTables.length; li += 1)
    {
        loTable = faArrayTables [li];
        loPgfTbl = loTable.FirstRowInTbl.FirstCellInRow.FirstPgf;
        loTRange = new TextRange ();
        loTRange.beg.obj = loPgfTbl;
        loTRange.beg.offset = 0;
        loTRange.end.obj = loPgfTbl;
        loTRange.end.offset = Constants.FV_OBJ_END_OFFSET-1;
        foDoc.TextSelection = loTRange;
        foDoc.ScrollToText (loTRange);
        Fcodes ([FCodes.KBD_TBL_DLG_UNIFY_TF]);
    }

    I had a FrameScript which did the same thing. There I had used an FCode to update the table format. I only copied that approach to ExtendScript.

    I had to go into one of the table cells. I do not know, if the text range and the scrolling is needed. Anyway, then I could update the table format with this Fcode command.

    1 reply

    Winfried RengCommunity ExpertAuthorCorrect answer
    Community Expert
    January 8, 2026

    @Klaus Göbel has helped me to get on track.

    Here is the correct loop:

    for (var li = 0; li < faArrayTables.length; li += 1)
    {
        loTable = faArrayTables [li];
        loPgfTbl = loTable.FirstRowInTbl.FirstCellInRow.FirstPgf;
        loTRange = new TextRange ();
        loTRange.beg.obj = loPgfTbl;
        loTRange.beg.offset = 0;
        loTRange.end.obj = loPgfTbl;
        loTRange.end.offset = Constants.FV_OBJ_END_OFFSET-1;
        foDoc.TextSelection = loTRange;
        foDoc.ScrollToText (loTRange);
        Fcodes ([FCodes.KBD_TBL_DLG_UNIFY_TF]);
    }

    I had a FrameScript which did the same thing. There I had used an FCode to update the table format. I only copied that approach to ExtendScript.

    I had to go into one of the table cells. I do not know, if the text range and the scrolling is needed. Anyway, then I could update the table format with this Fcode command.

    Community Expert
    January 8, 2026

    OK. Scrolling not needed. Only the text range.