Lost in translation (for JS)

Hi all

I wrote an applescript script, but I need to convert it to JavaScript to ensure compatibility with a 3rd party pugin.

I'm having a bit of badly translated the following section of code from as to JS.

Tell application "Adobe InDesign CS5"

Set DocumentLinks to the path of file of all links in the active document

tell the end

So far, I have the following js:

var documentLinks = [];

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

for (var myCounter = 0; myCounter < myDocument.allGraphics.length; myCounter ++) {}

var myGraphic = myDocument.allGraphics [myCounter];

myLink var = myGraphic.itemLink;

var myPath = myLink.filePath;

var documentLinksCount = documentLinks.push (myPath);

}

When I try to run it with a specific indesign document, I get the error 'null is not an object' and the ' var myPath = myLink.filePath; ' line is highlighted.

I think that this error occurs because as "myDocument.allGraphics.length;" has a value of 19 with this document, but when I look at the links manually palette in indesign, I see only 18 links.

so somehow, I have a picture on the page that has one track zero which is causing my script for the error.

can someone tell me the best approach to work around this problem?

Thank you!

Sorry, my code there was an error:

var documentLinks = app.activeDocument.links.everyItem().filePath;

Substances

Tags: InDesign

Similar Questions

Maybe you are looking for