A simple Numbers workflow

Here’s a simple AppleScript I should’ve written a while ago. It saves me a few steps when creating and filling out a new expense report.

As I’ve mentioned before, I have a simple two-table Numbers template for my expense reports. The table in the top right has just two cells for the date of the report and its label; the table that takes up most of the sheet has the usual cells for the expenses themselves.

Expense report after opening

Once upon a time, I had an alias for the template file in my Dock. I could click on it and Numbers would launch (assuming Numbers wasn’t already running—usually a safe bet with me) and open a new document formatted according to the template. At some point—possibly with Mavericks, possibly with the more recent versions of Numbers—that stopped working. Clicking the template file on the Dock would launch Numbers, but it wouldn’t create a new file from the template.

So for the past several months, I’ve been making expense reports this way:

  1. Launch Numbers.
  2. Tell it I want a new file.
  3. Scroll down through the list of templates to select my expense report template.
  4. Click in the date field to enter today’s date.
  5. Click in the main table to start entering expenses.

While doing this today I realized how silly it was to keep repeating those steps, so I wrote this AppleScript, which I call “Open Expense Template”:

applescript:
 1:  set today to current date
 2:  tell application "Numbers"
 3:    make new document with properties {document template:template "Expenses"}
 4:    -- delay 2 -- might have to wait for Numbers to launch
 5:    tell document 1
 6:      tell sheet 1
 7:        tell table 1 to set value of cell 1 of column 2 to today
 8:        tell table 2 to set selection range to range "A2:A2"
 9:      end tell
10:    end tell
11:    activate
12:  end tell

It does all five steps in one go. I have it saved in a folder that LaunchBar indexes, so I can run it by typing “oet” or just “oe” in LaunchBar. When the script finishes, the expense report file looks just like the screenshot above. The date of the report is entered and the top left cell of the expense table is selected, ready to be filled.

You might be wondering about a few things: