Highlighted

How to format the numbering number in a paragraph style via script?

Explorer ,
Apr 30, 2020

Copy link to clipboard

Copied

I'd like to create a paragraph style with numbering, however, I'd like to change the Number option in the Numbering style from default ^#^t to ^#. I could not find any class here that would help me to accomplish this.

 

It is quite simple to do via GUI, see the screenshot below.

 

tukusejssirs_1-1588280068568.png

 

Currently, my script looks like this:

 

var doc = app.activeDocument;
var newStyleName = 'New Style';
var newStyle = doc.paragraphStyles.itemByName(newStyleName);
var footnotesStartAt = 5;

// Create `newStyleName` paragraph style if missing
if (! newStyle.isValid) {
   newStyle = app.documents[0].paragraphStyles.add();
   newStyle.name = newStyleName;
   newStyle.bulletsAndNumberingListType = ListType.NUMBERED_LIST;
   newStyle.numberingFormat = NumberingStyle.ARABIC;
   // ??? newStyle.??? = '^#';
   newStyle.numberingStartAt = footnotesStartAt;
}
Adobe Community Professional
Correct answer by Manan Joshi | Adobe Community Professional

Try the following

newStyle.numberingExpression = "^#"

 

-Manan

TOPICS
Scripting

Views

90

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

How to format the numbering number in a paragraph style via script?

Explorer ,
Apr 30, 2020

Copy link to clipboard

Copied

I'd like to create a paragraph style with numbering, however, I'd like to change the Number option in the Numbering style from default ^#^t to ^#. I could not find any class here that would help me to accomplish this.

 

It is quite simple to do via GUI, see the screenshot below.

 

tukusejssirs_1-1588280068568.png

 

Currently, my script looks like this:

 

var doc = app.activeDocument;
var newStyleName = 'New Style';
var newStyle = doc.paragraphStyles.itemByName(newStyleName);
var footnotesStartAt = 5;

// Create `newStyleName` paragraph style if missing
if (! newStyle.isValid) {
   newStyle = app.documents[0].paragraphStyles.add();
   newStyle.name = newStyleName;
   newStyle.bulletsAndNumberingListType = ListType.NUMBERED_LIST;
   newStyle.numberingFormat = NumberingStyle.ARABIC;
   // ??? newStyle.??? = '^#';
   newStyle.numberingStartAt = footnotesStartAt;
}
Adobe Community Professional
Correct answer by Manan Joshi | Adobe Community Professional

Try the following

newStyle.numberingExpression = "^#"

 

-Manan

TOPICS
Scripting

Views

91

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
Apr 30, 2020 0
Adobe Community Professional ,
Apr 30, 2020

Copy link to clipboard

Copied

Try the following

newStyle.numberingExpression = "^#"

 

-Manan

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
Reply
Loading...
Apr 30, 2020 0
Explorer ,
Apr 30, 2020

Copy link to clipboard

Copied

I've missed the `numberingExpression` class. Thanks! This works as expected. 🙂

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
Reply
Loading...
Apr 30, 2020 0