Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

applescript - replace text in specific text frame

New Here ,
Jun 05, 2012 Jun 05, 2012

Throwing another one out there to is excellent forum:

I know how to change text in a document:

tell application "Adobe InDesign CS5.5"

          set find text preferences to nothing

          set change text preferences to nothing

 

  --Search the document for the string.

          set find what of find text preferences to "SigBelowT"

 

  --Replace the search with what we pulled from the db

          set change to of change text preferences to theSigCopyB

 

  -- this is the actual search and replace command

          set myFoundItems to change text

end tell

I'm trying to change text only in a specific paragraph, named as a layer in my source inDesign Document:

tell application "Adobe InDesign CS5.5"

          tell the active document

                    try

                              set find text preferences to nothing

                              set change text preferences to nothing

                              set Text_Frame to the text frame "PH"

                              set find what of find text preferences to "~" of text frame Text_Frame

                              set change to of change text preferences to " "

                              set myFoundItems to change text

                    end try

          end tell

end tell

I've tried several iterations similiar to this one, but I'm not hitting the right combination.

Suggestions??



TOPICS
Scripting
5.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

People's Champ , Jun 05, 2012 Jun 05, 2012

Hi,

Ok, you may need to tweak this snippet a bit. Right now, it will only apply changes to so names "foo" text frames.

tell application "Adobe InDesign CS5.5"

          set find text preferences to nothing

          set change text preferences to nothing

          set find what of find text preferences to "~"

          set change to of change text preferences to " "

          tell active document

 

                    set tfs to all page items

                    repeat with i from 1 to count of tfs

    

...
Translate
People's Champ ,
Jun 05, 2012 Jun 05, 2012

Hi,

I don't have exact syntax at hand but paragraphs have a findGrep method. So I guess you should write something like

tell myparagraph

    set result to find grep

end tell

again, teh synatx is up to you but you get the idea. Besides what do you mean by "named as a layer in my source inDesign Document"?

Loic

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 05, 2012 Jun 05, 2012

Hi -

It's named as an element under on a layer of the document.

I use that name to find elements to change fonts, etc.  Just can't find the way to limit the search and replace to that text frame using that name.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 05, 2012 Jun 05, 2012

headed down this path:

tell application "Adobe InDesign CS5.5"

          try

                    set myDoc to active document

                    set Text_Frame to the text frame "PH"

                    set find text preferences to nothing

                    set change text preferences to nothing

 

                    set find what of find text preferences to "~"

                    set change to of change text preferences to " "

                    tell myDoc

                              tell Text_Frame

                                        set myFoundItems to change text

                              end tell

                    end tell

          end try

end tell


still not working

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Jun 05, 2012 Jun 05, 2012

Hi,

Ok, you may need to tweak this snippet a bit. Right now, it will only apply changes to so names "foo" text frames.

tell application "Adobe InDesign CS5.5"

          set find text preferences to nothing

          set change text preferences to nothing

          set find what of find text preferences to "~"

          set change to of change text preferences to " "

          tell active document

 

                    set tfs to all page items

                    repeat with i from 1 to count of tfs

                              set tf to item i of tfs

                              if name of tf = "foo" then

  change text of tf

                              end if

                    end repeat

 

          end tell

end tell

Loic Aigon

http://www.loicaigon.com

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 05, 2012 Jun 05, 2012
LATEST

Perfection!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines