For this particular string, I built an alternate scheme which apply to the three components of iPlay and to many others except Numbers '09:
on getLocalizedTitle(theApp) activate application theApp tell application "System Events" to tell (first process whose frontmost is true) keystroke "f" using {command down} delay 0.2 set wTitle to title of front window keystroke "w" using {command down} end tell return wTitle end getLocalizedTitle
set title_loc to my getLocalizedTitle("Pages")
Yvan KOENIG (VALLAURIS, France) mardi 4 mars 2014 19:19:04
Here is a subset of the script designed to merge in Pages.
property saveInPages : false property useDictionarySyntax : false
on run my Germaine() end run
on Germaine()
# Exit if the running Pages is not version 5.x if version of application "Pages" does not start with "5" then error localized string "PE96" in bundle path to application "Finder" end if
# Builds the folder in which the merged documents will be stored
tell application "System Events" set dossierDestination to path of (make new folder at end of folder "~/Desktop" with properties {name:my stamper_horodateur()}) end tell
# Main loop
repeat 2 times tell application "Pages" tell document 1 # file_fichier_Pages # it's the master document used to merge in end tell # Create a duplicate of the master document my duplicateIt() delay 1 log (get name of documents)
# Builds an unique name set nouveauNom to my stamper_horodateur() # Insère les valeurs dans la copie qui vient d'être créée
if saveInPages then # Save as Pages document if useDictionarySyntax then save document 1 in file (dossierDestination & nouveauNom & "b.pages") as Pages --> Le document « master - copie » n’a pas pu être exporté sous le nom « merged 20140304_162717b.pages ». --> com.apple.security.pboxd a quitté de manière imprévue. --> the syntax given in the Dictionary fails with : error number -10000 else save document 1 in file (dossierDestination & nouveauNom & ".pages") --> Behaves well delay 1 end if end if # Export as PDF export document 1 to file (dossierDestination & nouveauNom & ".PDF") as PDF if saveInPages then # From time to time, issue this error : --> com.apple.security.pboxd a quitté de manière imprévue. end if close document 1 without saving end tell delay 1 end repeat end Germaine
#=====
on duplicateIt() activate application "Pages" tell application "System Events" to tell (first process whose frontmost is true) keystroke "s" using {command down, shift down} end tell end duplicateIt
#=====
on stamper_horodateur() tell (current date) to return "merged " & (((its year) * 10000 + (its month) * 100 + (its day)) as text) & "_" & text 2 thru -1 of ((1000000 + (its hours) * 10000 + (its minutes) * 100 + (its seconds)) as text) end stamper_horodateur
#=====
If I run this exact version with a Pages document open at front, I get correctly to PDF files in the target folder on the Desktop.
If I set the property saveInPages to true, most of the times it works but from time to time I get an error message containing : --> com.apple.security.pboxd a quitté de manière imprévue. If I set both properties saveInPages and useDictionarySyntax to true, The process fails with the error message : --> Le document « master - copie » n’a pas pu être exporté sous le nom « merged 20140304_162717b.pages ».
I'm really puzzled because I use exactly the syntax described in the dictionary.
Am I understanding the dictionary the wrong way or is it an oddity somewhere ?
Here is the dictionary's contents : save v : Save a document. save specifier : The document(s) or window(s) to save. [in file] : The file in which to save the document. [as Pages] : The file format to use.
In practice, I will keep only the PDF format because it's fine to print all the generated document in a single task : select all the PDFs open in Preview Print which will print the entire set of files.
Yvan KOENIG (VALLAURIS, France) mardi 4 mars 2014 21:15:17
|