Question

I am new to InDesign scripting though I do have experience with Javascript. I created a new menu item as you will see in the script below, which I planned to use it to call another script onclick. However I am facing some issues, so I decided to delete the menu item and start over. But at line 10, I get the message "undefined is not an object", which I can't figure out why it's causing a problem.

Any help will be appreciated.

//#targetengine "ImportFolder"

//var myMainMenu = app.menus.item("Main");
//var myCustomMenu = myMainMenu.submenus.item("Import Folder");
//var myCustomMenu = myMainMenu.submenus.add("Import Folder");
//var mySampleScriptAction = app.scriptMenuActions.add("onInvoke", function() {
//app.doScript(new File ("/C/Program Files (x86)/Adobe/Adobe InDesign CS6/Scripts/Scripts Panel/importFiles.jsx" ));});

//delete the menu
var myMainMenu = app.menus.item("Main");
try{
var myCustomMenu = myMainMenu.submenus.item("Import Folder");
myCustomMenu.remove();
}catch(myError){}
Was it helpful?

Solution

Try re-installing Indesign. If the scripting library dll lost its registration, it could cause all of the scripts to fail.

...wait a minute - are you trying to use this script from the Extendscript Toolkit? If you are, you have to change engines.

Also, if you have more than one version of CS on your system, you need to make sure you use the Extendscript Toolkit that matches the version of your InDesign - in other words, EXTK CS6 for IND CS6.

enter image description here

Another thing to try is to remove the new from your doscript command. I like to wrap mine in a function like this:

//run a script from the CS6 Script Panel Directory (be sure to add the file extension
function RunMyScript(whatscriptname){
    app.doScript(File("/C/Program Files (x86)/Adobe/Adobe InDesign CS6/Scripts/Scripts Panel/" + whatscriptname));
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top