Skip to main content
Inspiring
September 16, 2013
Answered

How to suppress "modal dialog or alert" when the script is in process?

  • September 16, 2013
  • 1 reply
  • 1981 views

Dear all,

I created a script which will place text from rtf files from a folder to an active document on different page based on match. But if a font which was in doc file but not present in my mac, showed error while running the script.

That means Indesign opened a missing font alert box and script stop at that line and the error its shows "cannot handle the request because a modal dialog or alert is active".

Is is possible to suppress this error and script continue to place all RTF files? i have little knowledge on try/catch.

#target Indesign

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

var sourceFolder = Folder("/Users/admin4/Desktop/ec_txt");

myFiles = sourceFolder.getFiles("*.rtf");

var myFrame1 = myDoc.pageItems.itemByID(111076);  // switerland

var myFrame2 = myDoc.pageItems.itemByID(111114);  // eurozone

var myFrame3 = myDoc.pageItems.itemByID(111146);  // germany

for (var i=0; i < myFiles.length; i++)

{

    switch (myFiles.name.slice (6, myFiles.name.lastIndexOf("_")))

        {

        case "Switzerland_en":

        myFrame1.parentStory.insertionPoints.item(-1).place(File (sourceFolder + "/" + myFiles.name))

        break;

        case "Eurozone_en":

        myFrame2.parentStory.insertionPoints.item(-1).place(File (sourceFolder + "/" + myFiles.name))

        break;

        case "Germany_en":

        myFrame3.parentStory.insertionPoints.item(-1).place(File (sourceFolder + "/" + myFiles.name))

        break;

}

}

This topic has been closed for replies.
Correct answer Green4ever

To suppress the alerts you can use user interaction levels.

app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;

Do not forgot to reset after the completion of the script with the following:

app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;

Hope it solves your request.

--------

Green4ever

1 reply

Green4ever
Green4everCorrect answer
Inspiring
September 16, 2013

To suppress the alerts you can use user interaction levels.

app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;

Do not forgot to reset after the completion of the script with the following:

app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;

Hope it solves your request.

--------

Green4ever

Inspiring
September 16, 2013

Many Thanks. it worked......

its similar like Application.ScreenUpdating = False (in VBA for excel)

is it also possible to use "Preset" (RTF import options) which i made for importing RTF files?

Virender