Skip to main content
Inspiring
May 29, 2023
Answered

Scripting: Reset Table Style and Cell Style Defaults Possible?

  • May 29, 2023
  • 2 replies
  • 642 views

Hi there!

 

If nothing is selected in a document, the user can still choose defaults in all styles panels (character, paragraph, object, table, cell styles). With

 

app.activeDocument.textDefaults.[...]
app.activeDocument.pageItemDefaults.[...]

 

I can change those defaults as I like. But I haven't found a setting to change table and cell style defaults.

 

So my question is:

Is it somehow possible to reset table and cell style defaults as it is with paragraph, character, and object style defaults with a script?

 

Thanks,
Tobias

This topic has been closed for replies.
Correct answer Peter Kahrel

> What is the corresponding code for table and cell styles?

 

As far as I can tell it's not possible to set default table and/or cell styles in the way you can for the other styles. Rob's suggestion is a workaround for this absent feature..

2 replies

Peter Kahrel
Community Expert
Peter KahrelCommunity ExpertCorrect answer
Community Expert
May 30, 2023

> What is the corresponding code for table and cell styles?

 

As far as I can tell it's not possible to set default table and/or cell styles in the way you can for the other styles. Rob's suggestion is a workaround for this absent feature..

Inspiring
May 31, 2023

Thank you for your clarification, Peter! And Rob for the workaround for some use cases.

rob day
Community Expert
Community Expert
May 29, 2023

Hi Tobias, Are you creating the table via a script? If that’s the case maybe set the default style in the add method’s properties parameter—here my "default" style is named MyDefault

 

var ip = app.activeDocument.selection[0].insertionPoints[0];
var dt = app.activeDocument.tableStyles.itemByName("MyDefault")

var t = app.documents[0].stories[0].tables.add(LocationOptions.AT_BEGINNING, ip, {appliedTableStyle:dt})

 

Before run:

After

Inspiring
May 30, 2023

Thanks Rob for your input, but I meant something else:

The user can select a table (and cell) style without selecting any object in the document – so before running the script there is a selected table and/or cell style:

 

And I want to change this user default to table and cell style "[None]" – so after running the script no table and cell style is selected:

So I’m looking for something to reset user selection (without any selected object in a document) of table and cell style which is similar to resetting user selection (without any selected object in a document) of character and paragraph styles:

var aDoc = app.activeDocument;
aDoc.textDefaults.appliedCharacterStyle = aDoc.characterStyles.item(0);
aDoc.textDefaults.appliedParagraphStyle = aDoc.paragraphStyles.item(0);

What is the corresponding code for table and cell styles?

 

Thanks, Tobias.