最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Adobe InDesign CS6 "undefined is not an object" - Stack Overflow

programmeradmin2浏览0评论

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){}

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){}
Share Improve this question edited Apr 3, 2014 at 15:02 Ria S. asked Apr 3, 2014 at 14:34 Ria S.Ria S. 632 silver badges11 bronze badges 3
  • Which line is line 10? var myMainMenu = app.menus.item("Main");? – Kevin B Commented Apr 3, 2014 at 15:04
  • @KevinB: it should be, because the rest of this mini-script is protected against run-time errors with the try..catch construction. However ... purely theoretically, that line should not have failed; alert (myMainMenu.submenus.everyItem().name); works for me. – Jongware Commented Apr 3, 2014 at 15:13
  • This is not the only script that this is happening. On a second script I get the exact same message (undefined is not an object), on the very 1st line (var myDocument = app.documents.add();). – Ria S. Commented Apr 3, 2014 at 16:31
Add a ment  | 

1 Answer 1

Reset to default 7

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.

Another thing to try is to remove the new from your doscript mand. 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));
}
发布评论

评论列表(0)

  1. 暂无评论