At the moment I’m making an attempt to open an existing pages document so that I can write a single line at the end of it. so far I have the following:
tell application "Finder" to set myFile to ("Users:themightyllama:Dropbox:Applescripts:The Droplet 3 Output") --as text --folder of the front window
tell application "Pages"
activate
set the_file to make new document
save the_file in myFile
close the_file
quit "Pages"
delay 5
tell application "Pages" to open for access "The Droplet 3 Output.pages" of "Users:themightyllama:Dropbox:Applescripts:" as alias with write permission
write finalText to myFile starting at eof
close access myFile
end tell
end tell
At this point in time, I can’t even save the script. I get
Can’t get “The Droplet 3 Output.pages” of “Users:themightyllama:Dropbox:Applescripts:”. Access not allowed.
I’ve attempted sooo many combinations over the past couple of hours. Any advice is very very welcome.
an colon separated HFS path starts always with a disk name (even referencing the startup volume).
But there’s a “shortcut”: path to home folder points to the home folder of the current user.
set myFile to ((path to home folder as text) & "Dropbox:Applescripts:The Droplet 3 Output")
Open for access is a command dedicated to text files, it is not relevant for Pages documents.
Look at the Pages Applescript dictionary to learn which commands are allowed.
Here is a short sample :
set leDocument to (path to desktop as text) & "aa.pages:"
tell application "Pages"
open leDocument
set nomDuDocument to name of document 1
tell document 1 to tell body text
set last character to (get last character) & "Belebele"
end tell
end tell