4 Replies Latest reply on Feb 18, 2011 1:18 PM by jo2mendoza

    [AS] Convert Find/Replace Script from CS2 to CS4?

    mmrm

      This is what I used with CS2:

       

       

      tell application "Adobe InDesign CS2"
      tell document 1
      search (every text frame whose label is "Bottom Strip") for "XXX" replacing with RepCode
      search (every text frame whose label is "Bottom Strip") for "0009" replacing with Month1
      if RegionCode is "C" then search (every text frame whose label is "Bottom Strip") for "480" replacing with "303"
      close document saving yes
      end tell
      end tell
      It would search for text only in certain text frames that had the right script label.  Now it doesn't work and I can't figure out how to do a find/replace and also define the script label.  How is this done in InDesign CS4?

        • 1. Re: [AS] Convert Find/Replace Script from CS2 to CS4?
          Olav Martin Kvern Level 3

          Hi mmrm,

           

          Try something like this:

           

          tell application "Adobe InDesign CS4"

          set RegionCode to "C"

          --You'll have to fill in whatever RepCode is.

          set RepCode to "RepCode"

          --You'll have to fill in whatever Month1 is.

          set Month1 to "Month1"

          set find text preferences to nothing

          set change text preferences to nothing

          set find what of find text preferences to "XXX"

          set change to of change text preferences to RepCode

          tell document 1

          tell (every text frame whose label is "Bottom Strip") to change text

          end tell

          set find what of find text preferences to "0009"

          set change to of change text preferences to Month1

          tell document 1

          tell (every text frame whose label is "Bottom Strip") to change text

          end tell

          set find what of find text preferences to "480"

          set change to of change text preferences to "303"

          tell document 1

          if RegionCode is "C" then

          tell (every text frame whose label is "Bottom Strip") to change text

          end if

          close saving yes

          end tell

          set find text preferences to nothing

          set change text preferences to nothing

          end tell

           

          Thanks,

           

          Ole

          • 2. Re: [AS] Convert Find/Replace Script from CS2 to CS4?
            mmrm Level 1

            Ole,

             

            Thanks!!!  That works great.  Its part of a larger script where those variables get set earlier.

             

            MMRM

            • 3. Re: [AS] Convert Find/Replace Script from CS2 to CS4?
              jo2mendoza

              What if you just want to Find/Replace in the master page, not in the regular page.

               

              Here's my script:

               

              tell application "Adobe InDesign CS4"


                --set preferences to blank

                set find text preferences to nothing

                set change text preferences to nothing

               

               

              -- set what to look for and what to replace it with

              set find what of find text preferences to "xxxfilenamexxx"

              set change to of change text preferences to "This is the new FileName"

               

               

              -- run the find and replace command

              tell document 1

              tell (every text frame) to change text

              end tell

               

              --set preferences to blank

              set find text preferences to nothing

              set change text preferences to nothing

               

              end tell

               

               

              What do I need to modify so that it will only Find and Replace items in the Master Page? I've tried "tell every master page in document 1" but got an error message.

               

              Thanks in advance.


              • 4. Re: [AS] Convert Find/Replace Script from CS2 to CS4?
                jo2mendoza Level 1

                The key word in replacing text in the master page is this:

                 

                search (text frame (1) of master spread "A-Master" of document 1