admin管理员组文章数量:1026989
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
1 Answer
Reset to default 7Try 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));
}
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
1 Answer
Reset to default 7Try 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));
}
本文标签: javascriptAdobe InDesign CS6 quotundefined is not an objectquotStack Overflow
版权声明:本文标题:javascript - Adobe InDesign CS6 "undefined is not an object" - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745663871a2162058.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论