4 Replies Latest reply on Feb 16, 2012 9:07 PM by John Hawkinson

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

    seko0101 Level 1

      hi all

      i try to use indesign product sdk CS5 using com object to open and edit document with asp.net

      this error appear to me in this part of my code

       

                  InDesign.Application indApp = (InDesign.Application)Activator.CreateInstance(InDType, true);

              

                 indApp.ScriptPreferences.UserInteractionLevel = idUserInteractionLevels.idNeverInteract;

              

                  InDesign.Document objDoc = (InDesign.Document)indApp.Open(cstrInddFile, true, idOpenOptions.idDefault);

       

       

       

      Cannot handle the request because a modal dialog or alert is active.\\\   at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData) at InDesign.ScriptPreference.set_UserInteractionLevel(idUserInteractionL evels ) at _Default.Button1_Click(Object sender, EventArgs e)

       

      thanks advance

        • 2. Re: Cannot handle the request because a modal dialog or alert is active
          [Jongware] Most Valuable Participant

          seko0101 wrote:

           

          hi guys i really need help here

           

          There you go: InDesign SDK Forum

           

          Wasn't that hard to answer.

          • 3. Re: Cannot handle the request because a modal dialog or alert is active
            Dirk Becker Level 4

            Hi Jongware, Seko,

             

            just mentioning the keyword "SDK" does not make a com / .net / c# project a plugin. ;-) Actually I had redirected Seko here, because the problem should be the same across all kinds of high level / scripting languages.

             

            InDesign modal dialogs are a restricted situation. With few exceptions the user can't invoke most menus from within. When the native code of the dialog processes commands from within the dialog window, e.g. in order to support the preview checkbox/feature, the commands are diverted and collected for later implicit undo in case the user happens to press the cancel button. My guess is that most script statements are just blocked the same way as the menus so they do not interfere with that special undo mechanism. As Seko has learned, even setting the user interaction level of script preferences will fail.

             

            I do not know any direct solution for the problem. We can check the app.modalState even while the dialog is open, and then defer or abort the script rather than run into the error. As most of my scripting is still with CS4 and InDesign Server I have not tried that but eventually you can also schedule a handler for a later idle or window close event. Finally, if your script runtime is outside of InDesign's process (communicating via AppleEvent or com) and therefor still responsive, you may use OS features to send fake user events such as an ESC key to cancel the modal dialog.

             

            Dirk

            • 4. Re: Cannot handle the request because a modal dialog or alert is active
              John Hawkinson Level 5

              Time warp alert (2011)

               

              Dirk wrote:

              I do not know any direct solution for the problem. We can check the app.modalState even while the dialog is open, and then defer or abort the script rather than run into the error. As most of my scripting is still with CS4 and InDesign Server I have not tried that but eventually you can also schedule a handler for a later idle or window close event.

              Attempts to add a new app.idleTasks or to register a new eventListener fail with "Cannot handle the request because a modal dialog or alert is active." (InCopy CS5)

              I suppose one could attempt to queue up an operating system handler to deal with this, but that is unpleasant.

               

              "Oh well."

               

              Has anyone solved this problem since?

              Alternatively, does ActionScript offer a good answer?