2 Replies Latest reply on Nov 2, 2012 8:32 AM by Peter Kahrel

    Cannot handle the request because a modal dialog or alert is active.

    ramanan08

      Dear all,

           I am struggling to interact ScriptUI Dialog with InDesign. It always shows "Cannot handle the request because a modal dialog or alert is active.". My actual code is,

       

           var window = new Window("dialog", "Export");

           var button = window.add("button", undefined, "Export");

           button.bounds = [0, 0, 100, 60];

           button.onClick = function() {

               try {

                   var file = File.saveDialog("Export File", "*.xml");

                   window.close();

                   app.activeDocument.exportFile(ExportFormat.xml, file.fsName);

               } catch(err) {

                   alert(err);

               }

           }

           window.show();

       

      I tried with window.close(), window.active = false, but the error still remains.

       

      Thanks in advance.

        • 1. Re: Cannot handle the request because a modal dialog or alert is active.
          csm_phil Level 4

          Hi

           

          Please try the below JS code i have modified some changes.

           

          var w = new Window ("dialog");
          var myBut = w.add ("button", undefined, "EXPORT", {name: "ok"});
          var myName = app.activeDocument.name.split(".indd").join(".xml");
          if (w.show() == 1){
              try {
                   var myFolder = Folder.selectDialog("Select the folder", ""); 
                   app.scriptPreferences.userInteractionLevel=UserInteractionLevels.neverInteract;
                   var myInxfile = new File(myFolder.fsName+"/"+app.activeDocument.name.split(".indd")[0]+".xml");
                   app.activeDocument.exportFile(ExportFormat.XML, myInxfile);
                   } catch(err) {alert(err);}
               }
          app.scriptPreferences.userInteractionLevel = UserInteractionLevels.INTERACT_WITH_ALL;
          
          
          
          

           

          thx,

          csm_phil

          • 2. Re: Cannot handle the request because a modal dialog or alert is active.
            Peter Kahrel Adobe Community Professional & MVP

            Further to phil's answer, you get that error because you defined the window as a dialog, which locks out all other activity. Define it as a palette to solve your problem.

             

            Peter