1 Reply Latest reply on Jul 30, 2014 12:08 PM by Jump_Over

    How to clear all overrides in a story

    Team Steam

      Hi Everyone!

       

      I've been putting together a short script to clear all overrides in a story in which I have a cursor inserted. This is what I have so far:

       

      //Clear all overrides in the story of the text selection:
      app.selection[0].paragraphs.everyItem().clearOverrides();
      
      //Clear overrides in all cells of all tables of the story of the text selection: 
      try {
        app.selection[0].parentStory.tables.everyItem().cells.everyItem().texts[0].clearOverrides();
      }
      catch (e) {}
      
      

       

      It works well enough, but I have to select all to clear the overrides on paragraph styles. If I don't select anything, only the style overrides in tables are cleared.

      How would I modify line 2 to work the same as line 6? I've tried a few different things, but no dice!

       

      I'm going to make this another question:

      Can anyone suggest a good recent book or online resource to start learning scripting for Indesign?

      I've been loving what we can do with scripts, but I want to start understanding what I'm doing, not just how to do it.

       

      Thanks a bunch!

      Amy

        • 1. Re: How to clear all overrides in a story
          Jump_Over Level 5

          Hi,

           

          In case of modifying a code:

          clearOverrides() is a method ==> it means some procedure will be executed (simple or pretty complex).

          the target for this method is placed before it ==> here it is every paragraph which can be reached basing on selection.

           

          So your goal is to change a target to parentStory, I guesss.

          Modified line should look like:

          app.selection[0].parentStory.clearOverrides();
          
          
          
          
          
          

           

          It will work till selection has a property parentStory. A graphic frame - which also can be selected - has not, so code will end with an error.

           

          How to detect available object's properties and methods?

          Exam this huge help files published by [Jongware] here:

          Indesign JavaScript Help

           

          many help PDFs can be googled. Just try. I recommend Peter Kahrel books (any you can google out - in fact )

           

          Jarek