2016-08-21 1 views
0

J'ai suivi le Guide de script AppleScript Adobe InDesign CS6, et j'essaie de changer le texte que j'ai configuré.Applescript trouver un texte de la liste dans le document indesign

Actuellement, il fonctionne, mais il ne change la chaîne exacte « Apple » à « poire »

Est-il possible d'avoir findword mis en place une liste de chaînes comme « pomme », « fruit ». J'ai essayé de faire une liste mais nous avons eu cette erreur « Valeur non valide pour la propriété set 'trouver ce. Chaîne attendue ou rien,

Aussi quand il change le texte que je veux dégager complètement la zone de texte indesign et remplacer avec changeWord

en ce moment si quelque chose vient après « Apple » comme pomme123 il va changer à « Pear123 ». Je en ai besoin pour effacer la zone de texte et placez changeWord dans la zone de texte

Tout conseil serait grandement apprécié, ou juste être pointé dans la bonne direction

Merci!

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 

Répondre

1

Vous pouvez utiliser regex, cela remplacera tous les mots qui commencent par l'un des éléments de la liste.

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