2-3 01 全てのページのテキストフレーム内の文字を置換する(P.111)
部品作製
-- 検索ワードを返す
on searchWord()
tell application "Adobe InDesign CS6"
find what of find text preferences
end tell
end searchWord
-- 検索ワードの設定
on setSearchWord(myStr)
tell application "Adobe InDesign CS6"
set find what of find text preferences to myStr
end tell
end setSearchWord
-- 置換ワードを返す
on changeWord()
tell application "Adobe InDesign CS6"
change to of change text preferences
end tell
end changeWord
-- 置換ワードの設定
on setChangeWord(myStr)
tell application "Adobe InDesign CS6"
set change to of change text preferences to myStr
end tell
end setChangeWord
部品が揃ったので、まとめ
tell application "Adobe InDesign CS6"
-- 検索・置換ワードの初期化?
set find text preferences to nothing --[accept or nothing]
set change text preferences to nothing --[accept or nothing]
-- 検索・置換ワードの設定
tell me
setSearchWord("★")
log searchWord() -- イベント画面に出力
setChangeWord("OS X")
log changeWord() -- イベント画面に出力
end tell
tell active document
set pMax to number of page
repeat with myPage from 1 to pMax
set fMax to number of every text frame of page myPage
repeat with i from 1 to fMax
set myObj to text frame i of page myPage
change text parent story of myObj
end repeat
end repeat
end tell
end tell
実行結果