Search code examples
javascriptadobe-indesignextendscript

Can't invoke menu items in InDesign CC script


I can't invoke menu items in scripts. For example:

app.menuActions.item("$ID/Override All Master Page Items").invoke;
app.menuActions.item("$Override All Master Page Items").invoke;
app.menuActions.itemByID(6164).invoke;

app.menuActions.item("$ID/Select All").invoke;
app.menuActions.item("Select All").invoke;
app.menuActions.itemByID(276).invoke; 

alert("Done");

does nothing except show the alert at the end.

I've checked that the IDs are valid and the action name is unique (at least for "Override All Master Page Items") with:

myMenuActions = app.menuActions.itemByName("Override All Master Page Items").getElements();  
for (var i = 0; i < myMenuActions.length; i++) {  
          alert(myMenuActions[i].area + " " + myMenuActions[i].id);  
}

I've also read through Kaysan's guide to scripting menu items in InDesign but all to no avail.

Any idea what's going wrong? (I'd prefer to reference menu items by locale-independent names rather than IDs but I'd settle for anything at this stage.)

I'm running InDesign CC 2014 on Windows 10, and I'm using Notepad++ to edit scripts, not the Adobe ExtendScript environment, just in case that should be relevant. Thanks in advance!


Solution

  • You need to add () to .invoke as it's a method.

    So it should be:

    app.menuActions.item("$ID/Override All Master Page Items").invoke()

    Hope that helps

    John