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

Indesign - script personnal order for object style

Explorer ,
Nov 02, 2025 Nov 02, 2025

Hello,

I am looking to write a script to rearrange my object styles (with much subgroups) according to a personal order.
Just a short example:

MY_PRINCIPAL_STYLE_HORIZONTAL
MY_SECOND_STYLE_HORIZONTAL
MY_PRINCIPAL_STYLE_VERTICAL
MY_SECOND_STYLE_VERTICAL​


In this specific case, I saw that it required :

  1. - renaming with a number 
002_MY_SECOND_STYLE_HORIZONTAL
001_MY_PRINCIPAL_STYLE_HORIZONTAL
004_MY_SECOND_STYLE_VERTICAL​
003_MY_PRINCIPAL_STYLE_VERTICAL
  • - then sorting by name
001_MY_PRINCIPAL_STYLE_HORIZONTAL
002_MY_SECOND_STYLE_HORIZONTAL
003_MY_PRINCIPAL_STYLE_VERTICAL
004_MY_SECOND_STYLE_VERTICAL​
  • - and then removing the number.
MY_PRINCIPAL_STYLE_HORIZONTAL
MY_SECOND_STYLE_HORIZONTAL
MY_PRINCIPAL_STYLE_VERTICAL
MY_SECOND_STYLE_VERTICAL​

With ChatGpt and Mate, I make three scripts for the moment.  I'm stuck on part 2 taken from this post. This code app.menuActions.itemByID(113168).invoke();  doesn't always seem to execute correctly on each run.

I use Indesign 2021 in my work. Is there a better way to invoke this action?

TOPICS
Scripting
48
Translate
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 02, 2025 Nov 02, 2025

Hi @RYR9 ,

to sort object styles by name you could also use this menu action:

app.menuActions.itemByName( "$ID/SortObjectStylesName" ).invoke();

 

However, you could first check if the menu action is available (enabled) in the context you are using it:

var mA = app.menuActions.itemByName( "$ID/SortObjectStylesName" );

if( mA.enabled )
{
mA.invoke();
}
else
{
alert( "ERROR: " + mA.name + "is currently not enabled." )
};

 

Kind regards,
Uwe Laubender
( Adobe Community Expert )

Translate
Community Expert ,
Nov 02, 2025 Nov 02, 2025

Hi @RYR9 ,

to sort object styles by name you could also use this menu action:

app.menuActions.itemByName( "$ID/SortObjectStylesName" ).invoke();

 

However, you could first check if the menu action is available (enabled) in the context you are using it:

var mA = app.menuActions.itemByName( "$ID/SortObjectStylesName" );

if( mA.enabled )
{
mA.invoke();
}
else
{
alert( "ERROR: " + mA.name + "is currently not enabled." )
};

 

Kind regards,
Uwe Laubender
( Adobe Community Expert )

Translate
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
Mentor ,
Nov 02, 2025 Nov 02, 2025
LATEST

Some panels with lists or trees allow a selection of multiple items.

Some panel associated menu actions will consider such a panel selection, or within a contextual click the hit item, and work on that. They require that the panel is open and that there is such a selection.

You can't simulate the effect via a scripted invoke(). Fallbacks might work on every item or give up.
I do not know whether this is the case for your menu actions, but your "doesn't always seem" sounds like that.

 

Alternatively you (or your AI) could try the myObjectStyle.move(LocationOptions.…,parentOrSibling) method, it should work without the panel.

Translate
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