Copy link to clipboard
Copied
Hi Scripters,
InDesign CS4/CS5 is able to invoke menuActions using the below mentioned javascript code.
var myMenuAction = app.menuActions.item("$ID/Go to Item");
try {
myMenuAction.invoke();
}catch (err){exit();};
However when I use the same code in InDesign CS5.5 version, we are encountering "Action not enabled" error.
Note: Please select the required XML element from the Structure Panel before running this code.
Thanks & Regards
csm_phil
Hi, csm_phil!
Try:
app.scriptMenuActions.itemByID(78629).invoke();
It's working in my InDesign CS 5.5 v7.5.1 (german edition).
Uwe
Copy link to clipboard
Copied
Hi All,
Any update on the below request, Any one please look into this.
thx
csm_phil
Copy link to clipboard
Copied
Hi, csm_phil!
Try:
app.scriptMenuActions.itemByID(78629).invoke();
It's working in my InDesign CS 5.5 v7.5.1 (german edition).
Uwe
Copy link to clipboard
Copied
Hello csm_phil,
However when I use the same code in InDesign CS5.5 version, we are encountering "Action not enabled" error.
The Articles panel was added in CS5.5, so the name Go to Item is no longer unique. See here:
myMenuActions = app.menuActions.itemByName("Go to Item").getElements();
for (var i=0; i<myMenuActions.length; i++) {
alert(myMenuActions.area+"/"+myMenuActions.id);
}
Means you either need to invoke the action by id or do it through associatedMenuAction.
Larry
Copy link to clipboard
Copied
Hi, Laubendar & Larry,
Thanks for your support. Its working fine.
thx
csm_phil
Copy link to clipboard
Copied
A related issue, perhaps. I am trying to toggle Menu options via script, to set a user environment. To make sure that Window->Tools is checked, this always works:
try {
var myTools = app.menuActions.item("Tools").checked;
}
catch (e) {}
if (myTools ==false) {
try {
app.menuActions.item("Tools").invoke();
}
catch (e) {}
}
But I also want to toggle things that lack a checkmark, such as Hide Hidden Characters.
This returns different results depending on whether a document is open, and sometimes does not toggle the selection (Show/Hide) and returns different values for the .checked call.
try {
var myHidden = app.menuActions.item("Hide Hidden Characters").checked;
}
catch (e) {alert("Error"); }
if (myHidden ==false ) {
try {
app.menuActions.item("Hide Hidden Characters").invoke();
}
catch(e) {}
}
Sometimes this returns false, sometimes undefined. I have done many iterations, also looking for ("Show Hidden Characters").checked
The original code was written for InCopy. Any menu item that is truly checked is easily controlled. The ones that toggle Show/Hide are a mess in both InCopy and InDesign.
Am I using the wrong syntax?
Dick Conrad
Find more inspiration, events, and resources on the new Adobe Community
Explore Now