2 Replies Latest reply on Mar 25, 2013 12:51 PM by s_ashok

    Find & Replace the text and apply paragraph style in indesign CS2.

    s_ashok Level 1

      Hai below script are working in cs4 - cs5.5. i need to run the script in indesign cs2.

      can you please help.

       

       

       

      Main();

       

       

       

      function Main() {

       

          var foundItem;  

       

          var doc = app.activeDocument;

       

       

       

          //app.findTextPreferences = app.changeTextPreferences = NothingEnum.NOTHING;

       

      app.findTextPreferences.findWhat = "^p";

       

       

       

       

       

       

       

             //app.findTextPreferences.appliedParagraphStyle = "head";

       

        

       

          var foundItems = doc.findText();

       

          

       

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

       

              foundItem = foundItems[i];

       

              foundItem.applyParagraphStyle(doc.paragraphStyles.item("content body indent"), false);

       

                

       

          }

       

           app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.NOTHING;

       

           var myDocument = app.activeDocument;

       

      //Clear the find/change text preferences.

       

      app.findTextPreferences = NothingEnum.nothing;

       

      app.changeTextPreferences = NothingEnum.nothing;

       

      //Set the find options.

       

      app.findChangeTextOptions.caseSensitive = false;

       

      app.findChangeTextOptions.includeFootnotes = false;

       

      app.findChangeTextOptions.includeHiddenLayers = false;

       

      app.findChangeTextOptions.includeLockedLayersForFind = false;

       

      app.findChangeTextOptions.includeLockedStoriesForFind = false;

       

      app.findChangeTextOptions.includeMasterPages = false;

       

      app.findChangeTextOptions.wholeWord = false;

       

      //Search the document for the string "copy" and change it to "text".

       

       

       

      app.findTextPreferences.findWhat = "^p";

       

       

       

      app.changeTextPreferences.changeTo = "^p";

       

      myDocument.changeText();

       

      //Clear the find/change text preferences after the search.

       

      app.findTextPreferences = NothingEnum.nothing;

       

      app.changeTextPreferences = NothingEnum.nothing;

       

       

       

      }

       

       

       

      abc();

       

       

       

      function abc() {

       

          var foundItem;  

       

          var doc = app.activeDocument;

       

       

       

          //app.findTextPreferences = app.changeTextPreferences = NothingEnum.NOTHING;

       

      app.findTextPreferences.findWhat = "*";

       

       

       

       

       

       

       

             //app.findTextPreferences.appliedParagraphStyle = "head";

       

        

       

          var foundItems = doc.findText();

       

          

       

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

       

              foundItem = foundItems[i];

       

              foundItem.applyParagraphStyle(doc.paragraphStyles.item("RealEstate"), false);

       

                

       

          }

       

           app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.NOTHING;

       

           var myDocument = app.activeDocument;

       

      //Clear the find/change text preferences.

       

      app.findTextPreferences = NothingEnum.nothing;

       

      app.changeTextPreferences = NothingEnum.nothing;

       

      //Set the find options.

       

      app.findChangeTextOptions.caseSensitive = false;

       

      app.findChangeTextOptions.includeFootnotes = false;

       

      app.findChangeTextOptions.includeHiddenLayers = false;

       

      app.findChangeTextOptions.includeLockedLayersForFind = false;

       

      app.findChangeTextOptions.includeLockedStoriesForFind = false;

       

      app.findChangeTextOptions.includeMasterPages = false;

       

      app.findChangeTextOptions.wholeWord = false;

       

      //Search the document for the string "copy" and change it to "text".

       

       

       

      app.findTextPreferences.findWhat = "*";

       

       

       

      app.changeTextPreferences.changeTo = "";

       

      myDocument.changeText();

       

      //Clear the find/change text preferences after the search.

       

      app.findTextPreferences = NothingEnum.nothing;

       

      app.changeTextPreferences = NothingEnum.nothing;

       

       

       

      }

       

       

       

       

       

       

       

      ab();

       

      function ab () {

       

          var foundItem;  

       

          var doc = app.activeDocument;

       

       

       

          app.findTextPreferences = app.changeTextPreferences = NothingEnum.NOTHING;

       

          app.findTextPreferences.findWhat = " ^ ";

       

      app.changeTextPreferences.changeTo = " ";  

       

          //app.findTextPreferences.appliedParagraphStyle = "head";

       

        

       

          var foundItems = doc.findText();

       

        

       

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

       

              foundItem = foundItems[i];

       

              foundItem.applyParagraphStyle(doc.paragraphStyles.item("day"), false);

       

               

       

          }

       

       

       

          app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.NOTHING;

       

           var myDocument = app.activeDocument;

       

      //Clear the find/change text preferences.

       

      app.findTextPreferences = NothingEnum.nothing;

       

      app.changeTextPreferences = NothingEnum.nothing;

       

      //Set the find options.

       

      app.findChangeTextOptions.caseSensitive = false;

       

      app.findChangeTextOptions.includeFootnotes = false;

       

      app.findChangeTextOptions.includeHiddenLayers = false;

       

      app.findChangeTextOptions.includeLockedLayersForFind = false;

       

      app.findChangeTextOptions.includeLockedStoriesForFind = false;

       

      app.findChangeTextOptions.includeMasterPages = false;

       

      app.findChangeTextOptions.wholeWord = false;

       

      //Search the document for the string "copy" and change it to "text".

       

       

       

      app.findTextPreferences.findWhat = "^";

       

       

       

      app.changeTextPreferences.changeTo = "";

       

      myDocument.changeText();

       

      //Clear the find/change text preferences after the search.

       

      app.findTextPreferences = NothingEnum.nothing;

       

      app.changeTextPreferences = NothingEnum.nothing;

       

       

       

      }