Skip to main content
Inspiring
December 4, 2016
Question

How do I clear cell attributes not defined by a cell style in InDesign CS5?

  • December 4, 2016
  • 2 replies
  • 1003 views

I am writing a script in vbs for InDesign CS5 in Windows, and cannot find how to clear cell attributes not defined by a cell style in a table. I need this when importing tables from MS Word.

2 replies

Inspiring
December 6, 2016

I am working with text imported from Microsoft Word, and the top and bottom cell insets in a table are zero. I apply a cell style with top and bottom cell insets of 5 pt, but nothing happens to them until I click the 'clear attributes not defined by style' button at the foot of the cell styles panel. Then the insets are applied.

I would like to incorporate this step in a script.

Inspiring
December 6, 2016

I should add that I am working with Visual Basic, so find the discussion in javascript a bit difficult.

Inspiring
December 6, 2016

With a little experimenting, I have now solved the problem. Thanks Obi-Wan and Laubender .

Community Expert
December 4, 2016

Hi,

could you give an example for what you like to do? A simple case?

To what values should the undefined property/value pairs in the cell styles are cleared to?


The following thread is about ExtendScript's clearCellStyleOverrides() method, though.

Maybe not exactly what you want, but could be helpful perhaps.

How to break link to cell/table style in a selection

creativejoan0425 Dec 14, 2013

How to break link to cell/table style in a selection

Especially Marc Autret's post in the same thread here:

Re: How to break link to cell/table style in a selection

Regards,
Uwe

Obi-wan Kenobi
Legend
December 4, 2016

Hi Uwe,

[JS] to make Tables really "pure"!

Thanks for your comments! 

At the beginning: All kind of situations

First approach: the op keeps the cell styles manually applied but, now, really pure!

(the "yellow" cell in the first table was a "red" cell!)

app.doScript("main()", ScriptLanguage.javascript, undefined, UndoModes.FAST_ENTIRE_SCRIPT, "Pure Tables! …"); 

 

function main() 

{

   

   var  myDoc = app.activeDocument, 

        myCells = myDoc.textFrames.everyItem().tables.everyItem().cells.everyItem().getElements(), 

        C = myCells.length; 

        while( C-- )

            {

                myCells.clearCellStyleOverrides();

                myCells.texts[0].clearOverrides();

            }  

}

Second approach: Totally "pure" tables!

app.doScript("main()", ScriptLanguage.javascript, undefined, UndoModes.FAST_ENTIRE_SCRIPT, "Pure Tables! …"); 

 

function main() 

{

   

var  myDoc = app.activeDocument, 

     myCells = myDoc.textFrames.everyItem().tables.everyItem().cells.everyItem().getElements(), 

     C = myCells.length; 

        while( C-- )

            {

                myCells.clearCellStyleOverrides();

                myCells.appliedCellStyle = "[None]";

                myCells.texts[0].clearOverrides();

            }  

}

(^/)