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

Scripting: Reset Table Style and Cell Style Defaults Possible?

Engaged ,
May 29, 2023 May 29, 2023

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

TOPICS
Scripting
678
Translate
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 , May 30, 2023 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..

Translate
Community Expert ,
May 29, 2023 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:

Screen Shot 22.png

After

Screen Shot 23.png

Translate
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
Engaged ,
May 29, 2023 May 29, 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:

Bildschirmfoto 2023-05-30 um 07.37.17.png

 

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:

Bildschirmfoto 2023-05-30 um 07.37.38.png

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.

Translate
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
Community Expert ,
May 30, 2023 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..

Translate
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
Engaged ,
May 30, 2023 May 30, 2023
LATEST

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

Translate
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