MacTech AppleScript Essentials Column > Introduction to Scripting Microsoft Word

January, 2007 - Introduction to Scripting Microsoft Word.

Lately, there has been a lot of talk in the Macintosh community about Microsoft, and the forthcoming Office 12. One of Microsoft's big announcements is that they will be doing away with support for creating and running Visual Basic macros in the next version of Office. This leaves many people wondering how they will go about automating their Office applications. AppleScript to the rescue. I'm pleased to say that Entourage, Excel, PowerPoint, and Word are all AppleScriptable.

Office has supported AppleScript for some time now, and with the release of Office 11 in 2004, Microsoft actually completely re-implemented much of their AppleScript support, and also added AppleScript support for PowerPoint. Due to these changes, much of the AppleScript terminology in Word and Excel changed from previous versions. If you are currently using Office AppleScripts with a pre-2004 version of Office, then please be aware that you will probably need to make some modifications to your scripts when you decide to upgrade your Office suite. Of course, this should go without saying when upgrading any scriptable application. Any time any application is updated, AppleScript terminology changes may be introduced. This is why it is always a good idea to test your existing scripts with any new application version before implementing it into your live workflow.

This month, we're going to take a look at scripting Microsoft Word. We'll walk through some basic techniques for interacting with Word documents, and the content within those documents. Please note that all code in this month's column was written for and tested with Office 11 (2004). Therefore, if you're using a different version of Office, please be aware that the terminology you need to use may differ from that which I have used.

[Read more at]