• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to truly silently open a document?

Explorer ,
Mar 07, 2017 Mar 07, 2017

Copy link to clipboard

Copied

I'm using a script (see also related question) to export all documents of a book to IDML:

  1. var contents = app.activeBook.contents; 
  2. for(var i=0, content; i < contents.length; i++) { 
  3.     content = contents
  4.     var filename = content.fullName.fsName; 
  5.     var document = app.open(filename, showingWindow=false); 
  6.     var idmlname = filename.substr(0, filename.lastIndexOf(".")) + ".idml"
  7.     document.exportFile(format=ExportFormat.INDESIGN_MARKUP, to=File(idmlname)); 
  8.     document.close(saving=SaveOptions.NO); 

I'd like this process to be as unattended as possible, but unfortunately sometimes a cross-reference is outdated and I'm asked to update it there might also be other user-interaction interruptions I haven't yet encountered but would also like to cover).

Is there any way to open a document in a "yeah, just open it the way it is without asking the user"?

TOPICS
Scripting

Views

390

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

People's Champ , Mar 08, 2017 Mar 08, 2017

But before you exit, make sure to set it back!

try{

     app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;

}

catch(_){}

finally{

     app.scriptPreferences.userInteractionLevel = UserInteractionLevels.INTERACT_WITH_ALL);

}

Ariel

Votes

Translate

Translate
Guide ,
Mar 08, 2017 Mar 08, 2017

Copy link to clipboard

Copied

use the below line in first of your code..

app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT; 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Mar 08, 2017 Mar 08, 2017

Copy link to clipboard

Copied

LATEST

But before you exit, make sure to set it back!

try{

     app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;

}

catch(_){}

finally{

     app.scriptPreferences.userInteractionLevel = UserInteractionLevels.INTERACT_WITH_ALL);

}

Ariel

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines