Autonomia & Tecnologia

OS X Automation with Applescript to generate Word for Mac documents from templates

Autoword Project is an OS X automation based on Applescript Application to DRY the process of filling up Microsoft Word 2008 for Mac template documents.

As part of a selling processes, a friend had to fill up three documents with his client’s information: a letter, a label, and a warranty card. Doing this manually was extremely error prone and annoying.

So what if he could type his customer’s data once and get all the three documents ready to print? That’s what the Autoword Project do!

Autoword Project opens a Cocoa window with an input form and a “generate” button. The user enters the customer data and Autoword generates PDF files ready to print based on the given Microsoft Word 2008 for Mac template documents.

I had no intentions to create a generic program, since I had little time to do it and it was my first Applescript initiative. Instead I focused on develop a simple XCode Applescript Application that could serve as baseline to anyone who has similar needs. So adapting Autoword Project is simply a matter of:

  1. Set up the fields you need into the Cocoa window;
  2. Create a Word for Mac docx template file with the proper docvariable fields;
  3. Reference your template files in the beginning of the autoword.applescript;
  4. Adapt the buildDocument procedure to pass on your data if you changed the Cocoa form.

You can clone Autoword Project repository at GitHub. I encourage you to fork the project and improve it at your will. And if you have more ideas, it would be great to hear, so please drop me a comment.

você pode gostar também