Copy link to clipboard
Copied
hi this function on app.activedocument
doc.links.everyItem().update();
doc.save();
it not work my only link into indd file is .doc
thanks in advance
Copy link to clipboard
Copied
Hi @laurence roussel12011930 ,
your code should work for all placed and linked images.
You could also test something else:
// Create an array of all links of the document:
var allLinks = app.documents[0].links.everyItem().getElements();
// Loop the array:
for( var n=0; n<allLinks.length; n++ )
{
allLinks[n].update();
};
Or use relink(File) in the loop.
So you do a relink to the same file:
// Create an array of all links of the document:
var allLinks = app.documents[0].links.everyItem().getElements();
// Loop the array:
for( var n=0; n<allLinks.length; n++ )
{
allLinks[n].relink( allLinks[n].filePath );
};
Regards,
Uwe Laubender
( Adobe Community Expert )
Copy link to clipboard
Copied
Totally working on my side. Which InDesign version are you running?
Copy link to clipboard
Copied
on the last 2022 i will try to do a video
Copy link to clipboard
Copied
sorry i forget an information, error appear if only link is .doc AND this link is missing
Copy link to clipboard
Copied
Some pertinent questione would be
-Manan
Copy link to clipboard
Copied
visual code stop (wait the video is uploaded)
doc.links.everyItem().update();
Copy link to clipboard
Copied
Your issue is that link is actually missing (interrogation mark in red dot). So you are asking InDesign to update a link it just doesn't reach. Hence the failure.
If you can access the resource, you need to relink() and not update().
Otherwise, you are hitting a wall.
Copy link to clipboard
Copied
if (internal_link[k].status == LinkStatus.LINK_MISSING){
var folderPath = (File.openDialog(internal_link[k].filePath));
var imglist = Folder(folderPath).getFiles(internal_link[k].name+".*");
if (imglist.length == 1){
internal_link[k].relink(imglist[0]);
}
}
else {
doc.links.everyItem().update();
doc.save();
}
but
var imglist = Folder(folderPath).getFiles(internal_link[k].name+".*");
visual code tell than folder().getfiles is not a function
Copy link to clipboard
Copied
[EDIT]discard answer, can't remove message[/EDIT]
Copy link to clipboard
Copied
Why the use of getFiles anyway? If you know file location, just use a File object => .relink(File(linkPath));
Obviously check for File(linkPath).exists first.
Loic
Copy link to clipboard
Copied
Hi @Loic.Aigon,
I have been having this discussion with @laurence roussel12011930 on the code snippet he shared in his last post. It's difficult to understand what he is trying to achieve but do go through the discussion so far on the other thread. Probably I am missing something and you might be able to add in something that leads him to a solution
-Manan
Copy link to clipboard
Copied
Indeed, it reminds me at my early stage where every line of code was a questioning 🙂
Copy link to clipboard
Copied
exactly
Copy link to clipboard
Copied
because someone write me that.... ^^
if link is missing, we open a dial windows for choose the good file for replace, mean we will replace the oldfile path by new choosed