Safety Emporium - Lab and Safety Supplies

AppleScripting QuickBooks 2009 Mac

Script Examples and Techniques: Page 5

On the previous page we examined how to import data from Apple's Mail program, parse it, and bring it into QuickBooks 2009 Mac. On this page, we will get data from QuickBooks 2009 Mac send it to Apple Mail.

Exporting Data From QuickBooks 2009 Mac to Mail

Let's suppose we have an invoice open and would like to mail a copy to the customer along with some other information. We'll assume that we have a customer invoice open:

We have now exported the invoice as well as grabbed the customer's first name, last name, and email address. Now we will construct the body of our personalized email message and then we will tell Apple Mail to prepare the message for us.

And that's it. Your custom email message with the invoice attachment should be open and ready for you to review before sending.

You'll notice that we used a string of try statements with Mail. That's simply so that if any one of those fails, the rest of the message will still be constructed, and it makes debugging a lot easier. You could use just one try construction within or around the "tell Mail...end tell" block if you prefer.

Printing Statements and Reports

You can print statements and reports from QuickBooks 2009 Mac in the same way that we did for Invoices as shown above. Here are the specific lines of code you need to call up a specific customer's statement:

From that point on, the procedure for saving the statement as a PDF is the same as we saw previously for invoices. In fact, the printing process would make a good subroutine. Notice also that we could change the date range if we wanted to. Although it is beyond the scope of this tutorial, you could set the starting date to the first of the year or 90 days in the past if you wished to.

Here's the code to call up a memorized report.

From there, you can simulate pressing command-P to print as PDF just as we saw in the Invoice example above. Some examples of how to script non-memorized reports are given on Examples Page 1. In general, if you are scripting a report, then you should make that report a template by memorizing it.

On the next page, we'll look at code to automate basic payroll functions in QuickBook 2009 Mac.

Table of Contents

Safety Emporium - Lab and Safety Supplies

Copyright 2008-2016 by Interactive Learning Paradigms Incorporated. All rights reserved. Reposting of this material is not permitted and constitutes a violation of US and International copyright law.