2016-08-21 14 views
0

Adob​​e InDesign CS6 AppleScript Scripting Guideに従っています。設定したテキストを変更しようとしています。それは「りんご」、「フルーツ」のような文字列のリストとして設定findwordすることは可能ですAppleScriptでindesign文書のリストからテキストを検索

は現在、それは動作しますが、それだけで正確な文字列「アップル」に「梨」

を変更します。 私はそれをリストを作ってみましたが、設定されたプロパティのため、このエラー 」無効な値が 『見つける』だ。予想される文字列または何も、

また、それは私が完全にクリアInDesignのテキストボックスへと置換するテキストを変更したときそれ今changewordに

で何がApple123のような「アップル」の後に来る場合、それは「Pear123」に変更します。私はそれがテキストボックスをオフにし、何かアドバイスは次のようになり、テキストボックス

でchangewordに配置する必要があり大きな感謝、または正しい方向を指しているだけです。

ありがとう!

set findWord to "Apple" 
--establish text for change 
set changeWord to "Pear" 


tell application "Finder" to set indesignFiles to (files of folder "test1" whose name extension is "indd") as alias list 



tell application "Adobe InDesign CC 2015" 
    open indesignFiles 


    --Clear find text preferences 
    set find text preferences to nothing 
    --Clear change text preferences 
    set change text preferences to nothing 
    --establish properties for find 
    set find what of find text preferences to findWord 
    --establish properties for change 
    set change to of change text preferences to changeWord 
    --perform change text operation 
    tell document 1 
    change text 
end tell 
    set find text preferences to nothing 
    set change text preferences to nothing 

    if modified of active document is true then 
     tell active document to save 
    end if 


    tell active document 
     export format PDF type to "Macintosh HD:Users:mattsocha:Desktop:Test1:test.pdf" without showing options 
    end tell 

end tell 

答えて

1

正規表現を使用すると、リスト内のいずれかの項目で始まる単語が置き換えられます。

set findWord to "(apple|pear|peach|banana)\\w*" 
set changeWord to "fruit" 

tell application "Adobe InDesign CC 2015" 

set find grep preferences to nothing 
set change grep preferences to nothing 

set find what of find grep preferences to findWord 
set change to of change grep preferences to changeWord 


tell document 1 
    change grep 
end tell 

set find grep preferences to nothing 
set change grep preferences to nothing 

end tell 
関連する問題