AppleScript to Print from Numbers to PDF

I want to use Applescript to automatically save an invoice worksheet to a folder with the invoice number as the file name.

The invoice number is an auto generated number. For the sake of this lets say its in cell A1 of Table 1 on Sheet 1.

This is what I have been able to find so far. Does not work as intended and also unable to figure out how to set the file name or location.

tell application "System Events"

tell process "Numbers"

keystroke "p" using command down

tell sheet 1 of window 1

click menu button "PDF"

repeat until exists menu 1 of menu button "PDF"

delay 0.02

end repeat

click menu item "Save as PDF…" of menu 1 of menu button "PDF"

end tell

end tell

end tell

Any help is greatly appreciated.

Show more Less

Posted on Jun 19, 2016 11:50 AM

Me too Me too Me too Me too Reply

Loading page content

Page content loaded

User level: Level 9 59,939 points

Can't help you directly, but you may find this information useful:

Note that the print dialogue is a drop down from the Script Editor window and shows the Script Editor 'page' in it's Preview window.

The Events log reports the error that stopped the script and shows the last line attempted in its window.

To view the Events report, click the 'page' icon at the bottom of the script editor window. (Marked by the V in the 'augmented' script below), then the Events button in the row above the report pane (darkened and peeking out from just below the Print dialogue in the image above).