Formatting tables

Contributor ,
Jun 08, 2021 Jun 08, 2021

Copy link to clipboard

Copied

Dear experts,
is there any way (a Script?) to format all tables in my project as I formatted the first one? In all tables: the first column has to be 56 mm wide, the second 13 mm, and the third 56 mm. Tables have from three to seven rows and the last row needs to be formatted with the "tab. bottom" Cell Style; other rows with "tab." Cell Style. Everything else is formatted as it should be.

Of course, I can do it one by one but there are over 1000 tables... Any ideas?

 

MJ

TOPICS
How to, Scripting

Views

204

Likes

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

Adobe Community Professional , Jun 08, 2021 Jun 08, 2021
Having a merged footer row complicates matters but something like this might work. Seemed to work on your sample but not sure what other pitfalls exists on your full document.  var tables = app.activeDocument.stories.everyItem().tables.everyItem(); tables.rows.lastItem().unmerge(); tables.columns[0].width = "56 mm"; tables.columns[1].width = "13 mm"; tables.columns[2].width = "56 mm"; tables.cells.everyItem().applyCellStyle(app.activeDocument.cellStyles.itemByName("tab."), true); tables.rows...

Likes

Translate

Translate
Adobe Community Professional ,
Jun 08, 2021 Jun 08, 2021

Copy link to clipboard

Copied

Having a merged footer row complicates matters but something like this might work. Seemed to work on your sample but not sure what other pitfalls exists on your full document. 

 

 

var tables = app.activeDocument.stories.everyItem().tables.everyItem();
tables.rows.lastItem().unmerge();
tables.columns[0].width = "56 mm";
tables.columns[1].width = "13 mm";
tables.columns[2].width = "56 mm";
tables.cells.everyItem().applyCellStyle(app.activeDocument.cellStyles.itemByName("tab."), true);
tables.rows.lastItem().cells.everyItem().applyCellStyle(app.activeDocument.cellStyles.itemByName("tab. bottom"), true);
tables.rows.lastItem().merge();

 

 

Likes

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
Contributor ,
Jun 08, 2021 Jun 08, 2021

Copy link to clipboard

Copied

Thank you very much! That works almost perfectly. Now I have good Celle Styles applied, but all are with +:

Zrzut ekranu 2021-06-08 195830.jpg

I can't find the right English name but now I have to hold left Alt and click on "tab." Cell Style to make all cells with my settings. Is there any way to run a second script that removes all overrides (those pluses) from applied styles?

 

Likes

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
Adobe Community Professional ,
Jun 08, 2021 Jun 08, 2021

Copy link to clipboard

Copied

app.activeDocument.stories.everyItem().tables.everyItem().cells.everyItem().clearCellStyleOverrides(true);

Likes

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
Contributor ,
Jun 08, 2021 Jun 08, 2021

Copy link to clipboard

Copied

This is weird. This removes all formatting from tables:

Zrzut ekranu 2021-06-08 205245.jpg

 

But when I choose Clear Overrides from the Cell Styles menu everything is as it should be.

Likes

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
Contributor ,
Jun 10, 2021 Jun 10, 2021

Copy link to clipboard

Copied

Any ideas on how to solve that problem?

Likes

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
Contributor ,
Jun 11, 2021 Jun 11, 2021

Copy link to clipboard

Copied

LATEST

I've changed "true" to "false" and now it is working as expected:

app.activeDocument.stories.everyItem().tables.everyItem().cells.everyItem().clearCellStyleOverrides(false);

 

Likes

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