5 Replies Latest reply on Jul 13, 2010 12:09 AM by sstanleyau

    AS find/replace on specific layer?

    max_technopia

      Hi is there a way to make a find/replace on a specific layer instead on all document?

       

      thanks to all

        • 1. Re: AS find/replace on specific layer?
          sstanleyau Level 4

          You can do it by targeting the command at the text frames on a particular layer. It's not foolproof if stories are threaded between layers, but fine in most cases you're likely to want to do it in.

          • 2. Re: AS find/replace on specific layer?
            max_technopia Level 1

            tryed this but it doesn't work:

             

            tell application "Adobe InDesign CS4"

            tell page1 of active document

            -- setto le preferenze di ricerca

            set find text preferences to nothing

            set change text preferences to nothing

             

            -- setto le preferenze di sostituzione

            set find what of find text preferences to "ciccio"

            set change to of change text preferences to "sup"

             

            -- eseguo ricerca

            tell active document

            set trovati to change text to layer1 of active document

            end tell

            end tell

            end tell


            • 3. Re: AS find/replace on specific layer?
              sstanleyau Level 4

              You probably need something like this:

               

              change text (every item of all page items whose class is text frame and item layer is layer 1)


              • 4. Re: AS find/replace on specific layer?
                tobias.wantzen Level 1

                It's more something like this:

                 

                set SearchString to "dolor"
                set ReplaceString to "ut"
                
                tell application "Adobe InDesign CS4"
                     set find text preferences to nothing
                     set change text preferences to nothing
                     set find what of find text preferences to SearchString
                     set change to of change text preferences to ReplaceString
                     
                     tell document 1
                          set allLayerItems to every page item of layer "layer2"
                          repeat with theItem in allLayerItems
                               tell theItem
                                    try
                                         set myFoundItems to change text
                                    on error
                                         log "no \"textual\" page item"
                                    end try
                               end tell
                          end repeat
                     end tell
                end tell
                
                

                 

                Cheers

                Tobias

                • 5. Re: AS find/replace on specific layer?
                  sstanleyau Level 4

                  sstanleyau wrote:

                   

                  You probably need something like this:

                   

                   

                  Actually, more like this:

                   

                  tell application "Adobe InDesign CS4"

                  set find text preferences to nothing

                  set change text preferences to nothing

                  set find what of find text preferences to "x"

                  set change to of change text preferences to "y"

                  set theLayer to layer 1 of document 1 -- or whatever

                  change text (every item of all page items of document 1 whose class is text frame and item layer is theLayer)

                  end tell