3 Replies Latest reply on Sep 2, 2016 10:58 AM by Skemicle

    Changing selected Paragraphs to Basic Paragraph style?

    cbishop01 Level 2

      I've look on here for about an hour and cannot find a discussion for this.  I see where it clears the overrides but not change Style all together.  Here's what i'm needing help doing.  If i have lets say 4 text boxes selected i would like the be able to Change the Paragraph style to Basic Paragraph and set Character style to None. If there is already A discussion i missed about this can you point me in that direction.  If not Can i please get some help with this. 

        • 1. Re: Changing selected Paragraphs to Basic Paragraph style?
          tpk1982 Level 4

          You can use find and replace method..

          • 2. Re: Changing selected Paragraphs to Basic Paragraph style?
            tpk1982 Level 4

            Here code to change paragraph style

             

            var mydoc = app.activeDocument;  
            var allTFrames = mydoc.textFrames;  
              
            for (var i = 0; i < allTFrames.length; i++) {  
              var tFrame = allTFrames[i];  
                var pStory = tFrame.parentStory;  
                var allParas = pStory.paragraphs.everyItem();  
                allParas.appliedParagraphStyle = app.activeDocument.paragraphStyles[1];  
            }  
            

             

             

            Regards,

            K

            1 person found this helpful
            • 3. Re: Changing selected Paragraphs to Basic Paragraph style?
              Skemicle Level 3

              You can usetpk1982's script to change all paragraphs to the basic paragraph. But if you want only the selected text frame then you will need to adjust thescript to change paragraph styles only in the selected text frames.

              basically replace line 2 with var allTFrames = app.selection;
              Also if you need to clear character styles this will need to be done before changing the paragraph style or the character styles will be removed and the formatting will be left as a local override.  Your final script after these changes would be:

               

              var mydoc = app.activeDocument;

              var myTFrames = app.selection;

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

                  var tFrame = myTFrames[i];

                  var pStory = tFrame.parentStory;

                  var allParas = pStory.paragraphs.everyItem();

                  pStory.characters.everyItem().appliedCharacterStyle = app.activeDocument.characterStyles[0];

                  allParas.appliedParagraphStyle = app.activeDocument.paragraphStyles[1];

              }

               

              note: instead of just replacing line 2 i also changed the variable name to reflect instead of leaving it as allTFrames; and added line 7.. Other than those two changes everything else was tpk1982's script

              2 people found this helpful