Copy link to clipboard
Copied
How to run a script on InDesign startup?
Or jast after it open one document?
Is there any method like Excel VBA "Auto_Open" ?
Copy link to clipboard
Copied
To make a script autorun on InDesign startup, put the script in a subfolder named "Startup Scripts" (under the app or user Scripts folder).
To make a script run on InDesign document opening, attach an event listener to the beforeOpen or afterOpen document event, e.g. (in JS):
app.addEventListener( "beforeOpen" , function(){alert("Opening a document...");} );
Note that the script must have a session persistence (#targetengine 'mysession') if your event handler is enclosed within. You alternately can put the event handler in an external file, then no session scope is required.
Copy link to clipboard
Copied
Thank you very much!
Copy link to clipboard
Copied
To make a script run on InDesign document opening, attach an event listener to the beforeOpen or afterOpen document event...
InDesign's before/afterOpen events are practically useless — they both are sent before the document layout window opens. So you can do nothing useful with the document except perhaps getting its name. The only solution, I know about, is to use APID Toolkit's docLoaded event. If you are interested, here you can find an example of using it.
Kasyan
Copy link to clipboard
Copied
Kasyan wrote last year:
InDesign's before/afterOpen events are practically useless — they both are sent before the document layout window opens. So you can do nothing useful with the document except perhaps getting its name. The only solution, I know about, is to use APID Toolkit's docLoaded event.
As of CS5, you should be able to queue an idle task in response to the open event and then the idle task can wait for whatever condition is necessary before performing its work.
Copy link to clipboard
Copied
John,
will that work in CS3?
Copy link to clipboard
Copied
No, CS3 did not have idle events. But really you should think about upgrading.
Also, you could have your script call out the operating system and have it start a process that waits and then calls back to InDesign. This would be ugly but doable.
Copy link to clipboard
Copied
Hi,
I have written following code...
#targetengine "session"
main();
function main(){
var myApplicationEventListener = app.eventListeners.add("beforeOpen",myEventInfo);
}
function myEventInfo(myEvent){
var docName = app.documents.item(0).name;
var myString = "Current Target: Import ::" + myEvent.currentTarget.name+ docName;
alert(myString);
}
as event is "beforeOpen", how to take a document object actually i want to get all links from a document.
Is it possible?
Thanks,
Copy link to clipboard
Copied
as event is "beforeOpen", how to take a document object actually i want to get all links from a document.
Is it possible?
No. Use the afterOpen events.
You could, I suppose, instantiate an afterOpen event handler in your beforeOpen event handler...but why would you do that?
Copy link to clipboard
Copied
Actually what is happening is when i am trying to open a document InDesign is crashing because of one corrupted image, so while openning a document i need to track which image is corrupted or invalid and handle it in a different way.
Copy link to clipboard
Copied
I don't know of any way of determining if an item is corrupted before crashing InDesign…
Harbs
Copy link to clipboard
Copied
Is it possible using APID toolkit?
Or any other way
Copy link to clipboard
Copied
Well, you can try moving the linked images so that InDesign cannot get to them, and then opening the document.
Or perhaps opening in a more recent version of InDesign.
Copy link to clipboard
Copied
you mean to say is move all linked images to some other location, and open document. Then how to track corrupted image
No .. I just dont get it..
Thanks,
Copy link to clipboard
Copied
Well, if it opens, then your theory was correct.
Move half the images back and try again.
Repeat until you know which ones.
Copy link to clipboard
Copied
Thank YOU!
i will have my IT guy look at this!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now