Macro I used to Download 200+ bank statements

I tweeted recently “Just used @keyboardmaestro to download 200+ bank statement PDFs from various accounts. Nice that it helps me too ;-)” and was asked to show the workflow, so here it is.

I had enabled electronic statements on my bank accounts, which meant I now had access to statements going back several years and wanted to download them all. The statements each had links like "statement 123" and pages of 40 or so of them. So I created a folder for the statements, and then set up a macro to iterate through the numers and execute a second macro for each statement:

The macro also sets a variable IncPath to 1 initially and 0 after that - because I want the second macro to specify the path of the destination folder the first time, but after that OS X will remember the destination path so it's not necessary. This was an optimisation to make it a bit faster as it turned out typing in the path each time was both a bit slow and also tended to allow the system to get behind and cause reliability problems.

The second macro took in variables Statement and IncPath and did all the work. As is often the case, it simply does the sequence I would do, one step at a time, with pauses thrown in as required - it was still going to be a lot faster than doing it manually, so pauses were not a big problem, and robustness was more important.

The macro simply does:

  • Click Safari Link ‘statement %Statement%’
  • Pause for 1 second and then until the page does not say "Loading" and then 1 more second.
  • Type the ⇧⌘S Keystroke - Save As… (its a PDF so no printing required).
  • Pause for 0.3 seconds and then until a button Save is enabled.
  • If the IncPath variable is 0
    • Just type the statement name
  • Otherwise
    • Type the ⇧⌘G Keystroke - go to folder
    • Pause for 0.5 Seconds
    • Insert Text ‘~/ScanSnap/MyBank/MasterCard/Prints/%Statement%.pdf%Return%’ by Typing
    • Pause for 0.3 Seconds
  • Pause until a button Save is enabled.
  • Press Button ‘Save’
  • Pause for 1 Seconds
  • Type the ⌘W Keystroke - close the statement window
  • Pause for 1 Seconds
  • Set Variable ‘IncPath’ to Text ‘1’

The final action makes sure that the default is always to specify the whole path (safer but slower) - only the loop can actually run the macro with IncPath set to 0.

Note that the macro did not come to me fully formed in a dream. It is simply built step by step. I initially set the first macro to just loop from 123 to 123 so it was only downloading a single file. And initially I didn't have the IncPath variation either. With it only doing one run of the second macro, I could build the macro up step by step and ensure that at the end of the macro I was where I needed to be, and could clearly see what the next action or two would be.

Initially I uses Click Safari Link and then Wait For Safari to Finish Loading and then Type the ⇧⌘S Keystroke. But it turns out when it is rendering a PDF it does not count as loading, so that didn't work reliably. So I ended up settling for the more convoluted pausing system.

There was a bunch of other trial and error to get it working reliably, but then it could download 60 statements in one go, far easier and quicker than I would be, and make no mistakes like I would have done after manually doing it twenty or thirty times. Plus I could play games on my iPhone while it did it's thing (although it only took more than a minute or two).

Download Statements Macro File.kmmacros (11 KB)

4 Likes