Skip to main content
Inspiring
October 19, 2022
Question

problem with .close(saveoption.yes) and doc.links.everyItem().update();

  • October 19, 2022
  • 1 reply
  • 1978 views

hi, sorry to disturb, but i have soon finish a script for open and update all link into a .indd file

 

i have 70 files wirth same construction type inside, and 68 files work correctly and 2-3 files block on doc.close(saveoption.yes)

 

ad i don t know really why...

 

wich alternative there is for force save without any question

i use 

app.scriptPreferences.userInteractionLevel = UserInteractionLevels.neverInteract;

 

when i return open the document sometime all is ok, but if i want do ctrl+s, it open a windows for propose where save, and for the other file there is not this windows...

 

 

second question: doc.links.everyItem().update();  it update all link inside the indd file, it update psd, .doc,.jpg,.png?

 

because i have a doubt about link with this type of document

into my script i will open all link idd type file, and before close my document i do doc.links.everyItem().update()

This topic has been closed for replies.

1 reply

Loic.Aigon
Legend
October 19, 2022

It's likely that the 2/3 files were never saved. So you ask InDesign "Please save files" but InDesign doesn't just know where to, so it asks. Why is it that the file is not saved? Maybe a file saved with a prior version of InDesign that is converted to the newer format as a new file with no save history. Same could happen with idml or indt.

Even if you force InDesign to not displauy dialogs, it doesn't have a choice. Sensei is not reday yet. To circumvent this, you can check document.filePath for file existence. If file exists, save(SaveOptions.YES) will do. Otherwise, if you know the genuine file path then save new file to old file save(File(oldFilePath)).

And yes, InDesign does update links given that the source link file exists and InDesign has access to it.

You may want to separate your posts for the specific concern. Otherwise, answers may cross and it gets confused.

 

Inspiring
October 19, 2022

file exist since long time, open and save and close, lot of time recently, and problem restart each time with script

Loic.Aigon
Legend
October 20, 2022

i have try this: 

        try {
        doc.save();
        doc.close();
        }catch(err){
        alert(err.line+" => "+err.message);
        }

 

 

and it work on the problematic file, now i test with more file

 

for exemple: it s not possible for me to understand why doc.close not work but try (doc.close), work.... it s not really easy when you are 0...


if the script fails without try/catch, there are 0, like 0 reasons it would wok just because you had try/catch. The only exception would be that you don't process the error.

Exemple: 

try{

 //bad code that throws error

}

catch(err){

     //no action at all here

}

 

In this case, error is thrown but your code would ignore it.

 

Anyway, a nth digression that gets us away from the original trouble, i.e. that closing/saving will in some case throw a dialog. The point of the simple test code was to check if the behaviour was reproducible. If not it means that the culprit is elsewhere in your code.

You are back to step by step debugguing.