Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


Align-Center text in 1st column of a table

Community Beginner ,
Jun 29, 2021 Jun 29, 2021

Copy link to clipboard

Copied

Hi guys,
I'm trying to save some time by using a script that'll work on tables but I'm facing a problem on 1 line.

I would like to Center the text of the first column, without using any paraphStyle.

Here is part of it.

   table.cells.everyItem().clearCellStyleOverrides(true);
   table.appliedTableStyle = "Main Table";

   table.cells.everyItem().leftInset = table.cells.everyItem().rightInset = "1.411 mm";
   table.cells.everyItem().topInset = table.cells.everyItem().bottomInset = "1.411 mm";
   table.cells.everyItem().verticalJustification = VerticalJustification.CENTER_ALIGN;
   table.columns[0].width = "10";
   table.columns[1].width = "76";

    //table.columns[0].cells.everyItem()... (what about here ??) ... Justification.CENTER_ALIGN;

    table.cells.everyItem().autoGrow = true;
    table.cells.everyItem().minimumHeight = "1.058 mm";

My challenge here is to fill the gap at the line

//table.columns[0].cells.everyItem()... (what about here ??) ... Justification.CENTER_ALIGN;

 

Any help will be appreciated 😉

TOPICS
Performance, Scripting

Views

35

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 29, 2021 Jun 29, 2021

Copy link to clipboard

Copied

Are you missing texts[0] ?

Be careful with everyItem() . Could crash your script or InDesign itself if some conditions are not met.

Take for example this line, that should remove the last row of every table in the document:

 

app.documents[0].stories.everyItem().tables.everyItem().rows[-1].remove();

 

That would crash InDesign if it happens that there is a table with only one header row and one single body row.

 

Regards,
Uwe Laubender

( ACP )

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 29, 2021 Jun 29, 2021

Copy link to clipboard

Copied

To target all cells in the first column of a table, it's:

table.columns[0].cells.everyItem().texts[0].justification = Justification.CENTER_ALIGN;

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
Community Beginner ,
Jun 29, 2021 Jun 29, 2021

Copy link to clipboard

Copied

LATEST

Thank you guys, I was definitely missing something …
I thought I needed to get around it with Texts/ appliedStyles and so on. It turns out to be far simpler.

Thanks a lot ^^ works as a charm !

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