4 Replies Latest reply on Feb 24, 2009 6:10 PM by (GraemeS)

    ID CS3 FindChange Paragraph Style - please help

      Hello,
      I'm using InDesign CS3 on Mac.
      We use the FindChange scripts quite a bit. (JSFindChangeList.txt) We've modified and added many lines to this script and works really well.
      I am however, attempting to modify a sample script to find some text in the document and change it to a Paragraph Style.
      We do perform this task using the Find/Change panel, find blahblah, and change it so it applies a particular Paragraph Style.
      I'd like to have this one one of our scripts we run to make life much easier, and quicker.

      I'm trying to search for an internal code word that we use to apply a Paragraph style to, using a script, and maybe I'm doing something wrong, but the error tells me it doesn't like the word 'Paragraph'

      The example/sample line I am trying to modify to suit my own need is:
      //More complex example:
      //text {findWhat:"^9^9.^9^9"} {appliedCharacterStyle:"price"} {include footnotes:true, include master pages:true, include hidden layers:true, whole word:false} Find $10.00 to $99.99 and apply the character style "price".

      I am trying to alter this line, to look for the word 'section_style', and apply the Paragraph Style we have called 'Section'.

      I have got this, but it doesn't work:
      text {findWhat:"section_style"} {appliedParagraphStyle:"Section"} {include footnotes:true, include master pages:true, include hidden layers:true, whole word:false} Find section_style and apply the paragraph style Section.

      As I said, the error tells me it's the word Paragraph. I've done some searching, but cannot find an example anywhere where a script will find some text, and apply a Paragraph style to it.

      Please help me if you can.

      Many thanks in advance.
      Graeme.
        • 1. Re: ID CS3 FindChange Paragraph Style - please help
          Level 1
          hi, no takers.
          maybe i need to ask another way.

          Using the "JSFindChangeList.txt" file, I would like to add a line of script/code to:
          find a given text string in my document,
          and apply a Paragraph Style to it.

          I thought this would be simple thing as it seems pretty easy to do it the find/replace dialog box. It also seems pretty simple to add code to find something and replace with something.

          Any ideas any of you gifted scriptical minded people?
          :-)

          Thanks.
          Graeme.
          • 2. Re: ID CS3 FindChange Paragraph Style - please help
            Level 1
            Hi Greame,

            Try something like this for the changeTo section:

            {appliedParagraphStyle:app.documents.item(0).paragraphStyles.item("Section")}
            

            Let me know if that works!

            Thanks,

            Ole
            • 3. Re: ID CS3 FindChange Paragraph Style - please help
              Level 1
              No luck I'm afraid Ole.

              I got an error message that is now different from my other attempts. I'll try to type the error message as accurately as I can below for you.. (it's a pity ID doesn't let me 'copy' the error message)

              JavaScript Error!

              Error Number: 25
              Error String: Expected: :
              Line: 1
              Source: app.findTextPreferences.properties =
              {findWhat:"section_style"};app.changeTextPreferences
              .properties =
              {appliedParagraphStyles.item
              ("Section")};app.findChangeTextOptions.properties =
              {include footnotes:true, include master pages:true,
              include hidden layers:true, whole word:false};
              Offending Text: footnotes

              Ole, the full line I used that got the error above was:
              text {findWhat:"section_style"} {appliedParagraphStyle:app.documents.item(0).paragraphStyles.item("Section")} {include footnotes:true, include master pages:true, include hidden layers:true, whole word:false} Find text section_style and apply my parastyle Section.

              The Offending Text message is now different from what I have been getting previously... I have been getting 'Offending Text: paragraph' when using the following code:
              text {findWhat:"section_style"} {applied paragraph style:paragraph style "price" of document 1} {include footnotes:true, include master pages:true, include hidden layers:true, whole word:false} Find text section_style and apply my parastyle Section.

              Thanks for your response Ole. As you guessed, I'm a bit of a noob, but I love the challenge - it's just a pity that this one has me bamboozled completely.

              Graeme
              • 4. Re: ID CS3 FindChange Paragraph Style - please help
                Level 1
                oops, I went back one step too far. The example where the code says:
                {applied paragraph style:paragraph style "price" of document 1}
                was another code I was trying to use. The word "price" was in fact "Section" in 'my' code..

                sorry to confuse.