Copy link to clipboard
Copied
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??
1 Correct answer
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
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
Perfection!

