Mobile app version of vmapp.org
Login or Join
Heady304

: Updating links based on pageItem name, not based on index of 'links.items' I have a indesign document with several images. I want to update these images with Adobe Indesign Scripting. The following

@Heady304

Posted in: #Adobe #AdobeIndesign #Javascript

I have a indesign document with several images. I want to update these images with Adobe Indesign Scripting. The following code works.

var file = new File ('/MyDisk/image01.png');
app.activeDocument.links.item(1).relink (file);
var file = new File ('/MyDisk/image02.png');
app.activeDocument.links.item(2).relink (file);


But you have to know the index of the link you want to change. If you're adding/deleting images on the page, this numbering can change. So I rather use the name of the pageItem itself. But I don't know how to do this.

With textItems, it is easy to refer to a object's name, but to change an image link by referring his name seems not possible.
example:

app.activeDocument.textFrames.item('text frame').contents= 'changed content';

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Heady304

1 Comments

Sorted by latest first Latest Oldest Best

 

@Odierno310

You can certainly use the name to target a collection's item:

var link = app.activeDocument.links.itemByName("myLink.jpg");
//Get sure the reference exists before any further action
if ( link.isValid ) link.relink ( … )

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme