Have some Applescript adapted from somewhere a few years ago, but it's got a problem I can't understand: it quits at the "export" line with the message error "The variable targetDocument is not defined." number -2753 from "targetDocument" Here's the script - what's wrong with the variable "targetDocument"? Thanks for any help! set theSourceFolder to (choose folder with prompt "Select a folder whose files you wish to convert to pdf:") tell application "Finder" set filesArray to every file of theSourceFolder whose name extension is "pages" end tell set theDestinationFolder to (choose folder with prompt "Select a folder where you want the converted files to be placed: ") tell application "Pages" to activate repeat with aFile in filesArray tell application "Finder" set fileAlias to aFile as alias set fileName to name of fileAlias set fileExtension to name extension of fileAlias end tell set theOriginalName to fileName -- remove extension set prevTIDs to AppleScript's text item delimiters set AppleScript's text item delimiters to "." & fileExtension as string set fileName to first text item of fileName set AppleScript's text item delimiters to prevTIDs -- prepare desktop folder path and name set docPathAndName to theDestinationFolder & fileName & ".pdf" as string tell application "Pages" -- open the file set targetDocument to open aFile -- convert it export targetDocument to docPathAndName as PDF -- close it close targetDocument saving no end tell end repeat tell application "Pages" to quit display dialog "Done!"