Skip to main content
Known Participant
February 26, 2009
Question

Apply Cell Style to a Table

  • February 26, 2009
  • 9 replies
  • 3239 views
Hi all,

Actually I have set some default properties for each cell in a table.

This is for CS3. I have selected a table. Now the problem is I am not able to apply the cell style through script. But I am able to do it manually.

Looping through cells and columns takes more time. To reduce it I have choosed this method. I am not able to get the correct method of doing it.

Thanks,
Hemi
This topic has been closed for replies.

9 replies

Known Participant
March 12, 2009
Thank you, Shane! Works like a charm. As does 'clear table style overrides' when targeting a table.
Participant
January 27, 2011

hi,

how can i create and apply cell/table style?

i am working in VC.NET.

Thanks

Inspiring
March 12, 2009
The AppleScript command is 'clear cell style overrides'.<br /><br />-- <br />Shane Stanley <sstanley@myriad-com.com.au><br />AppleScript Pro Sessions <a href=http://scriptingmatters.com/aspro>
Known Participant
March 12, 2009
Robin, I'd like to clear cell and table style overrides using AppleScript -- can you advise? Not sure how to parse the JS code you wrote above. I wonder if you could just tell me which is the key command to clear the local overrides?

Thanks,
Aaron
Known Participant
March 2, 2009
Thanks to Both.

Hemi
Known Participant
February 26, 2009
and before you apply CellStyle - first you need to call clear local formatting

Sub ClearCellStyleOverrides([ClearingOverridesThroughRootCellStyle As Boolean = False])
Member of InDesign.Cell
Clear Cell Style Overrides / ClearingOverridesThroughRootCellStyle: If true, clears all overrides, whether or not they are defined in the underlying cell style

because if do not do this - your new CellStyle will not work - this happens in VB on PC - maybe JS is better ...

so in JS this probably will be:

myTable.cells.itemByRange(0,-1).clearCellStyleOverrides;

robin

--
www.adobescripts.com
Inspiring
February 26, 2009
myTable.cells.itemByRange(0,-1).appliedCellStyle = myStyle;

which, I believe, is quicker than:

myTable.cells.everyItem().appliedCellStyle = myStyle;

Dave
Known Participant
February 26, 2009
I am trying to set the same cell style to all cells in the table.
Known Participant
February 26, 2009
CS3 Indesign, Javascript
Inspiring
February 26, 2009
Ah, you're using CS3. I'll delete the other topic.

Which scripting language have you tried? Are you trying to set the same cell style to all cells in the table or some mixture?

Dave