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

TabStop on all Items

Explorer ,
May 14, 2021 May 14, 2021

Copy link to clipboard

Copied

Hi, Ive found a code that will adjust a tab value, however it only adjusts the first entry. Is there a way to set the code on all tab characters? Thank you....

 

// Text is selected:
var paragraph = app.selection[0].paragraphs[0];

if( paragraph.tabStops.length == 1 )
{
paragraph.tabStops[0].properties =
{
alignment : TabStopAlignment.LEFT_ALIGN ,
position : "0.125in"
};
};

if( paragraph.tabStops.length == 0 )
{
paragraph.tabStops.add
(
{
alignment : TabStopAlignment.LEFT_ALIGN ,
position : "0.125in"
}
);
};
TOPICS
How to , Scripting

Views

348

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 2 Correct answers

Community Expert , May 14, 2021 May 14, 2021

And directly to your scripting question:

You have to loop through all paragraphs in your selection. Because of:

var paragraph = app.selection[0].paragraphs[0];

will change only the first paragraph (that means the .paragraphs[0]) in your selection.

Votes

Translate

Translate
Community Expert , May 14, 2021 May 14, 2021

Hi,

Just adding the loop that will run on paragraph length. 

 

 

var _paragraphs = app.selection[0].paragraphs;
for (var i = 0; i < _paragraphs.length; i++) {
    paragraph = _paragraphs[i];
    if (paragraph.tabStops.length == 1) {
        paragraph.tabStops[0].properties =
        {
            alignment: TabStopAlignment.LEFT_ALIGN,
            position: "0.125in"
        };
    };

    if (paragraph.tabStops.length == 0) {
        paragraph.tabStops.add
            (
                {
      
...

Votes

Translate

Translate
Community Expert ,
May 14, 2021 May 14, 2021

Copy link to clipboard

Copied

The easiest way for the future:

If you use a paragraph format, you no longer need the script. Just change the position of the tab stop in paragraph style.

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 ,
May 14, 2021 May 14, 2021

Copy link to clipboard

Copied

And directly to your scripting question:

You have to loop through all paragraphs in your selection. Because of:

var paragraph = app.selection[0].paragraphs[0];

will change only the first paragraph (that means the .paragraphs[0]) in your selection.

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
Explorer ,
May 14, 2021 May 14, 2021

Copy link to clipboard

Copied

How can I apply this loop? Im sorry, I know that this can be done using paragraph styles and tab settings, but what I want to do is include this tabstop to a number of commands on one script.

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 ,
May 14, 2021 May 14, 2021

Copy link to clipboard

Copied

Hi,

Just adding the loop that will run on paragraph length. 

 

 

var _paragraphs = app.selection[0].paragraphs;
for (var i = 0; i < _paragraphs.length; i++) {
    paragraph = _paragraphs[i];
    if (paragraph.tabStops.length == 1) {
        paragraph.tabStops[0].properties =
        {
            alignment: TabStopAlignment.LEFT_ALIGN,
            position: "0.125in"
        };
    };

    if (paragraph.tabStops.length == 0) {
        paragraph.tabStops.add
            (
                {
                    alignment: TabStopAlignment.LEFT_ALIGN,
                    position: "0.125in"
                }
            );
    }
}

 

 

NOTE: Did not try at my end (Not tested)

 

Best regards

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
Explorer ,
May 14, 2021 May 14, 2021

Copy link to clipboard

Copied

LATEST

Thank you so much @pixxxelschubser @Charu Rajput  

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