Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Why will this not work on startup?

Advisor ,
May 24, 2016 May 24, 2016

#targetengine "session"  

    var myDocument = app.documents.item(0);

    var myStory = myDocument.stories.item(0);

        myStory.trackChanges = true; 

I placed this script in the Startup Script folder but it gives me an error on line 3.  When i have the script in the Normal Script folder and Click on it it works.

TOPICS
Scripting
2.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Engaged , May 28, 2016 May 28, 2016

Please use the following code and let me know if all is well. I have made some modifications and explained below:

#targetengine session

var myEventListener = app.eventListeners.item("TurnTCon");

  

if (!myEventListener.isValid) {  

    myEventListener = app.addEventListener("afterOpen", doJob1 );  

    myEventListener.name = "TurnTCon";  

}  

  

function doJob(event) {

    try{

        if(event.parent.constructor.name == "Document") {

            var myDocument = event.parent;

            if(myDocument

...
Translate
Community Expert ,
May 25, 2016 May 25, 2016

You'll need an event listening mechanism to check, if a document is opened and react on that.

You have to realise, that a script in the startup scripts folder is executed immediately when starting InDesign.


At exactly this point in time no document is open. So your code will return an error.

Even if you launch InDesign by double-clicking a document.

Btw. You are asking this in the wrong forum, I think.

A moderator should move this question over to InDesign Scripting

Regards,
Uwe

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
May 25, 2016 May 25, 2016

Sorry i thought i was in the scripting Forum

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
May 31, 2016 May 31, 2016
LATEST

yes, need to changed doJob1 to doJob.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines