You don't have permission
I use sierra and pages latest version.
I tried applescript to export to docx and text file.
But I have error message "You don't have permission".
Other appescripts that I downloaded from some sites have same problem.
I thought Pages has a problem. I checked "sharing and permission" on the pages info. But no problem.
Here example.
-- p2word.applescript
-- Batch convert Pages documents to MS Word. Word documents written to original
-- path and filename. (e.g. /Users/viking/Desktop/foo.pages → /Users/viking/Desktop/foo.docx)
-- Aug 7, 2016: Tested on OS X 10.11.6 with Pages v5.6.2. Requires Pages v5, or later.
-- Version 1.2, VikingOSX, Apple Support Community, No warranties expressed or implied.
usescripting additions
property MSWord : {docx:"docx", doc:"doc"}
propertyWord_type : (docxofMSWord)
property Pages : {"com.apple.iwork.pages.sffpages", "com.apple.iwork.pages.pages"}
property fileCnt : 0 as integer
-- Double-click application for interactive mode
on run
try
set fileObjects to (choose filewith prompt "Get File" of typePageswithmultiple selections allowed)
openfileObjects
on error errmsg number errnbr
my error_handler(errnbr, errmsg)
end try
return
end run
-- drag & drop file(s) and folder(s) mode when compiled as an Application
onopenfileObjects
-- can only run this with Pages v5 or later
tell application "Pages" to set its_version to version of it
if its_version is less than "5.0" then
display alert "Requires Pages v5 or later" as critical giving up after 10
return
end if
repeat with aFile in fileObjects
tell application "System Events" to set {akind, pf} to {kind, package folder} of aFile
-- a package folder will also have a kind of "Folder"
if akind contains "Folder" and pf is false then
tell application "Finder"
set pages_list to (every item in entire contents of folder aFile whose kind is "Pages Publication") as alias list
end tell
repeat with pages_fileinpages_list
export_file(pages_file, Word_type)
end repeat
else if akind contains "Pages Publication" then
export_file(aFile, Word_type)
end if
end repeat
if fileCnt > 0 as integer then
display notification "Files exported to Word: " & (fileCnt as text) ¬
with title "Pages v5 File Export Facility" subtitle "Processing Complete"
set fileCnt to 0 as integer
end if
-- ensure that Pages quits when done
tell application "Pages" to if it is running then quit
return
end open
onexport_file(theFile, doc_ext)
tell application "System Events" to set package_folder to package folder of theFile as boolean
if false is in package_folder then
-- single file format
set exportDocument to text 1 thru -6 of (theFile as text) & doc_ext
else
-- package folder names end in ':' so trim that character from filename
set exportDocument to text 1 thru -7 of (theFile as text) & doc_ext
end if
tell application "Pages"
try
with timeout of 1200 seconds
set mydoc to open theFile
exportmydoctofileexportDocumentasMicrosoft Word
end timeout
closemydocsavingno
set fileCnt to (fileCnt + 1) as integer
on error errmsg number errnbr
myerror_handler(errnbr, errmsg)
set fileCnt to 0 as integer
tell application "Pages" to if it is running then quit
return
end try
end tell
-- Overriding Pages default behavior to hide the document extension on export
tell application "Finder"
set extension hidden of (file exportDocument as alias) to false
end tell
return
endexport_file
onerror_handler(nbr, msg)
return display alert "[ " & nbr & " ] " & msg as critical giving up after 10
enderror_handler
--
--
macOS Sierra (10.12.2), null