9 Replies Latest reply on Oct 20, 2010 8:10 AM by Poo_Del

    Spell Check

    Poo_Del

      Hi All,

      Below code is working if spell check is not done, then it does not allow user to close the file automatically opens the document. Problem I am facing with after running spell check also it keeps opening the document.

       

      Can any one tell me wher is the problem?

       

      #target indesign
      #targetengine "session"
      var myLastDoc;
      var myConfirm;
      var myCheckSpellEvList = app.menuActions.item("Check Spelling...").addEventListener("beforeInvoke", myCheckSpellHandler, false);
      var myBeforeCloseEvList = app.addEventListener("beforeClose", myBeforeCloseHandler, false);
      var myAfterCloseEvList = app.addEventListener("afterClose", myAfterCloseHandler, false);
      function myBeforeCloseHandler(myEvent)
      {
          myConfirm = false;
          if (!eval(myEvent.parent.extractLabel("SpellingChecked")) && myEvent.parent.saved == true)
          {
              myLastDoc = myEvent.parent.fullName;
              myConfirm = confirm("Do you want to check spelling now?", false, "You forgot to check spelling!");
          }
      }
      function myAfterCloseHandler(myEvent)
      {
          if (!eval(myEvent.parent.extractLabel("SpellingChecked")))
          {
              if (myConfirm)
              {
                  app.open(myLastDoc);
                  app.menuActions.item("Check Spelling...").invoke();
              }
          }
          app.open(myLastDoc);
      }
      function myCheckSpellHandler(myEvent)
      {
          app.activeDocument.insertLabel("SpellingChecked", "true");
      }

       

      Regards,

      Poo Del

        • 1. Re: Spell Check
          Kasyan Servetsky Level 5

          What you posted is not the final version of the script.

          /* CheckSpelling.jsx
          Version 1
          This script is written to remind a user to spell-check the current document.
          Put this script into Startup scripts folder and restart InDesign if it's running. */
          #target indesign
          #targetengine "session"
          var myLastDoc;
          var myConfirm;
          var myCheckSpellEvList = app.menuActions.item("Check Spelling...").addEventListener("beforeInvoke", myCheckSpellHandler, false);
          var myBeforeCloseEvList = app.addEventListener("beforeClose", myBeforeCloseHandler, false);
          var myAfterCloseEvList = app.addEventListener("afterClose", myAfterCloseHandler, false);
          function myBeforeCloseHandler(myEvent){
             myConfirm = false;
             if (!eval(myEvent.parent.extractLabel("SpellingChecked")) && myEvent.parent.saved == true){
                myLastDoc = myEvent.parent.fullName;
                myConfirm = confirm("Do you want to check spelling now?", false, "You forgot to check spelling!");
             }
          }
          function myAfterCloseHandler(myEvent){
             if (!eval(myEvent.parent.extractLabel("SpellingChecked"))){
                if (myConfirm) {
                   app.open(myLastDoc);
                   app.menuActions.item("Check Spelling...").invoke();
                }
             }
          }
          function myCheckSpellHandler(myEvent){
             app.activeDocument.insertLabel("SpellingChecked", "true");
          }

          Kasyan

          • 2. Re: Spell Check
            mindsteam Level 1

            Hello, I guess first I'll ask what you want to accomplish via your script? To verify that the document is spell checked each time before closing?

             

            We have two commercial products which really simplify this, MindSpell and MindSpell Pro.

             

            With MindSpell 1.3 we're adding "spell check" and "suggest" events to the "word" script object. Very easy to have a script iterate all words in your text and check each word.

             

            Even simpler, use Preflight rules with MindSpell Pro. Just open the document, apply the MindSpell Pro profile and generate a preflight report.

             

            Here's a screenshot... With MindSpell Pro 1.1 we're adding suggested words to the 'Fix' text for each misspelled word. It will be in the output of the spelling report as well.

             

            MindSpellPro_1_1.png

             

            More info here:

             

            http://www.mindsteam.com/products/mindspell/index.html

            http://www.mindsteam.com/products/mindspellpro/index.html

             

            The updated versions will be released next week.

             

            Best regards,

            Heath Horton

            Mindsteam Software

            • 3. Re: Spell Check
              Harbs. Level 6

              Hi Heath,

               

              Very cool! This is something I requested some time back.

               

              Very nice to see that you included this scripting support!

               

              Best,

              Harbs

              • 4. Re: Spell Check
                mindsteam Level 1
                • 5. Re: Spell Check
                  Harbs. Level 6

                  Heath,

                   

                  Your post was blank.

                  • 6. Re: Spell Check
                    Poo_Del Level 1

                    Dear Kasyan,

                    It is working fine. What I am looking is if any users try to close the files it should ask for spell check. It doesn't allow users to close the document that means if users are clicking on "NO" then it should re-open the document.

                     

                    What is happening in this script is if user's are clicking on "NO" then it close the document. Rest of all is fine.

                     

                     

                    Regards,

                    Poo

                    • 7. Re: Spell Check
                      Poo_Del Level 1

                      /* CheckSpelling.jsx
                      Version 1
                      This script is written to remind a user to spell-check the current document.
                      Put this script into Startup scripts folder and restart InDesign if it's running. */
                      #target indesign
                      #targetengine "session"
                      var myLastDoc;
                      var myConfirm;
                      var myCheckSpellEvList = app.menuActions.item("Check Spelling...").addEventListener("beforeInvoke", myCheckSpellHandler, false);
                      var myBeforeCloseEvList = app.addEventListener("beforeClose", myBeforeCloseHandler, false);
                      var myAfterCloseEvList = app.addEventListener("afterClose", myAfterCloseHandler, false);
                      function myBeforeCloseHandler(myEvent){
                         myConfirm = false;
                         if (!eval(myEvent.parent.extractLabel("SpellingChecked")) && myEvent.parent.saved == true){
                            myLastDoc = myEvent.parent.fullName;
                            myConfirm = confirm("Do you want to check spelling now?", false, "You forgot to check spelling!");
                         }
                      }
                      function myAfterCloseHandler(myEvent)
                      {
                         if (!eval(myEvent.parent.extractLabel("SpellingChecked")))
                         {
                            if (myConfirm)
                            {
                               app.open(myLastDoc);
                               app.menuActions.item("Check Spelling...").invoke();
                            }
                        else
                        {
                            app.open(myLastDoc);
                          }
                         }
                      }
                      function myCheckSpellHandler(myEvent){
                         app.activeDocument.insertLabel("SpellingChecked", "true");
                      }

                       

                      I have added else condition to re-open the file. But it gives error that on that line. I trired many times to re-open the file if user is clicking on "No".

                       

                      Regards,

                      Poo

                      • 8. Re: Spell Check
                        Kasyan Servetsky Level 5

                         

                        The afterClose and beforeClose events are very specific: they can run a handler but can't prevent the document from closing. That's why my script does some bizarre acrobatics: If the document has not been spellchecked yet, it asks user if he wants to check spelling -- if he clicks NO, the document is closed, if he clicks YES, the document is closed, reopened and Spell Check menu is invoked. That's how it works (the script in post #1).

                         

                         

                        Regards,

                        Kasyan

                        • 9. Re: Spell Check
                          Poo_Del Level 1

                          Some where I have seen re-opening the document. I want to control the users to closing the files until and unless they have not run the spell check.

                           

                          Regards,

                          Poo