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

Indesign set columns TabStop Position problem

Community Beginner ,
Nov 19, 2017 Nov 19, 2017

Copy link to clipboard

Copied

hi all,

I have a question to set the tabstop position,

according below script is fail,

I can't set the tab stop position value to every single columns

can anyone help me?

thanks a lot!!

var myTable = app.selection[0].columns.everyItem();

var mySetCol = myTable.cells.everyItem().texts.everyItem();

mySetCol.tabStops.add({alignment: TabStopAlignment.CHARACTER_ALIGN, alignmentCharacter: ".", position: myTable.width - 4})

TOPICS
Scripting

Views

1.2K

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

Community Expert , Nov 20, 2017 Nov 20, 2017

And if you want to calculate the tab's position from the right edge of a cell, you could do it like that:

 

 

var textsArray = app.selection[0].cells.everyItem().texts.everyItem().getElements();

var tabStopProperties =
{
    alignment : TabStopAlignment.CHARACTER_ALIGN ,
    alignmentCharacter : "."
};

for(var n=0;n<textsArray.length;n++)
{
    var cellWidth = app.selection[0].cells[0].width;
    var position = cellWidth - 4;
    textsArray[n].tabStops.everyItem().remove();
    textsArray[n].t
...

Votes

Translate

Translate
Guide ,
Nov 19, 2017 Nov 19, 2017

Copy link to clipboard

Copied

Not sure why you used column.everyitem()..this will apply only for tables

Here is a way to start.. change as per your requirement..

var paras = app.activeDocument.stories.everyItem().paragraphs.everyItem().getElements();

for(var i=0;i<paras.length;i++)

{

    paras.tabStops.everyItem().remove();

    paras.tabStops.add( );

    var tabstops = paras.tabStops;

    tabstops[0].alignment = TabStopAlignment.LEFT_ALIGN;

    tabstops[0].position = "8pt";

    //  tabstops[1].remove;

}

Votes

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 ,
Nov 20, 2017 Nov 20, 2017

Copy link to clipboard

Copied

thanks a lot for your reply!

but I try it and can't solve my problem

the picture is what I want to do

select columns and set tabstop

in my case I try my script before when I type "position: myTable.width - 6"

it will count 2 columns total width -6 (70-6)

but I just want to set every column -6 (35-6)

test.jpg

Votes

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
Guide ,
Nov 20, 2017 Nov 20, 2017

Copy link to clipboard

Copied

The picture shows you are using tables and not tabbed text tables..

not sure what you want with column values..

it shows three columns.. please mention column 1, 2 and 3 values you need.

Votes

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 Expert ,
Nov 20, 2017 Nov 20, 2017

Copy link to clipboard

Copied

Hi together,

if you are working on a selection of text cells you can do it like that:

 

var textsArray = app.selection[0].cells.everyItem().texts.everyItem().getElements();

var tabStopProperties =
{
    alignment : TabStopAlignment.CHARACTER_ALIGN ,
    alignmentCharacter : "." ,
    position : "29mm"
};

for(var n=0;n<textsArray.length;n++)
{
    textsArray[n].tabStops.everyItem().remove();
    textsArray[n].tabStops.add();
    textsArray[n].tabStops[0].properties = tabStopProperties;
};

 

No need to access paragraphs. Just work with the texts object of a cell.

 

Regards,
Uwe

 

IMPORTANT NOTE:

Transferring this thread from the old forum to the new Adobe InDesign forum in 2019 damaged the posted code. Fixed it now.

Uwe Laubender, March 23, 2020.

Votes

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 Expert ,
Nov 20, 2017 Nov 20, 2017

Copy link to clipboard

Copied

And if you want to calculate the tab's position from the right edge of a cell, you could do it like that:

 

 

var textsArray = app.selection[0].cells.everyItem().texts.everyItem().getElements();

var tabStopProperties =
{
    alignment : TabStopAlignment.CHARACTER_ALIGN ,
    alignmentCharacter : "."
};

for(var n=0;n<textsArray.length;n++)
{
    var cellWidth = app.selection[0].cells[0].width;
    var position = cellWidth - 4;
    textsArray[n].tabStops.everyItem().remove();
    textsArray[n].tabStops.add();
    textsArray[n].tabStops[0].properties = tabStopProperties;
    textsArray[n].tabStops[0].position = position;
};

 

 

Regards,
Uwe

 

IMPORTANT NOTE:

Transferring this thread from the old forum to the new Adobe InDesign forum in 2019 damaged the posted code. Fixed it now.

Uwe Laubender, March 23, 2020.

Votes

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 ,
Nov 20, 2017 Nov 20, 2017

Copy link to clipboard

Copied

Thanks Laubender!

ITS WORK and GREAT!!

THANKS so much!!!

Votes

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 Expert ,
Nov 20, 2017 Nov 20, 2017

Copy link to clipboard

Copied

LATEST

BTW: You could also write the widths of all selected cells to an array beforehand and use the stored values in the loop.

Regards,
Uwe

Votes

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