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})
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
...
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;
}
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)
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.
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.
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.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
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