• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

ExtendScript - How to remove condition from a table

Community Expert ,
Jan 30, 2025 Jan 30, 2025

Copy link to clipboard

Copied

Hi,

I have a script which should remove conditions from a table.

This is based on Rick's blog post:

http://frameautomation.com/removing-conditions-from-text-and-table-rows-part-2/

 

To test my attempt, create a document with a table, apply a condition (or several) to the table rows and place the insertion mark in the table.

Here is my script attempt:

#target framemaker
"use strict";
#strict on

var loDoc, loTbl, loTRange, loTblCell;
loDoc = app.ActiveDoc;
loTRange = loDoc.TextSelection;
loPgf = loTRange.beg.obj;
loTblCell = loPgf.InTextObj;
loTbl = loTblCell.CellRow.RowTbl;
RemoveCondFmtFromTbl (loTbl);

function RemoveCondFmtFromTbl (foTbl)
// From Rick Quatro.
// http://frameautomation.com/removing-conditions-from-text-and-table-rows-part-2/
{  
    var loRow, laArrayInCond;
    // Remove all conditions from the list and update the row.
    loRow = foTbl.FirstRowInTbl;
    while (loRow.ObjectValid()) {
        laArrayInCond = loRow.InCond;
        $.writeln ("     laArrayInCond: " + laArrayInCond + "\n" +
            "     laArrayInCond.length: " + laArrayInCond.length);
        laArrayInCond.length = 0;
        loRow.InCond = laArrayInCond;
        loRow = loRow.NextRowInTbl;
    }
} // --- end RemoveCondFmtFromTbl

The values of the laArrayInCond are listed correctly.

However, when I set the array length to 0 and apply the array to a table row, nothing happens.

 

When I remove conditions from the paragraphs with the table anchor, then this works, but I have to press CTRL+L. loDoc.Reformat/RehyphenateloDoc.Redisplay; does not work.

However, CTRL+L does not help here.

Thank you very much for your help!

Best regards, Winfried

Views

43

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Feb 03, 2025 Feb 03, 2025

Finally I found a solution. There was a script from Klaus Daube, and @Klaus Göbel pointed me to a missing line (setting also isval). Thank you very much!

This function removes all conditions from all table rows.

function RemoveCondFmtFromTbl (foTbl)
// From Klaus Göbel.
{  
    var loRow, lProps, lPropIndex;
    // Remove all conditions from the list and update the row.
    loRow = foTbl.FirstRowInTbl;
    while (loRow.ObjectValid()) {
        lProps = loRow.GetProps ();
        lPropIndex = Get
...

Votes

Translate

Translate
Community Expert ,
Feb 03, 2025 Feb 03, 2025

Copy link to clipboard

Copied

LATEST

Finally I found a solution. There was a script from Klaus Daube, and @Klaus Göbel pointed me to a missing line (setting also isval). Thank you very much!

This function removes all conditions from all table rows.

function RemoveCondFmtFromTbl (foTbl)
// From Klaus Göbel.
{  
    var loRow, lProps, lPropIndex;
    // Remove all conditions from the list and update the row.
    loRow = foTbl.FirstRowInTbl;
    while (loRow.ObjectValid()) {
        lProps = loRow.GetProps ();
        lPropIndex = GetPropIndex (lProps, Constants.FP_InCond);
        lProps [lPropIndex].propVal.osval.length = 0; 
        lProps [lPropIndex].propVal.isval.length = 0;
        loRow.SetProps (lProps);
        loRow = loRow.NextRowInTbl;
    }
} // --- end RemoveCondFmtFromTbl

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines