Chapter 49. Microsoft Office

Tim Meadowcroft

Working in the Microsoft world of Windows, Office, Visual Basic, and loosely structured user documents, situations regularly appear in which you’d like to use Perl to tweak a piece of data or perform some task, but can’t because you’re deep in the Microsoft way of doing things. Normally, integration is hard to achieve, but this article describes how you can grab that little bit of Perl when you want it using tools from ActiveState’s Perl Development Kit.

Microsoft tools tend to integrate well with other Microsoft tools, and not at all with anything else. And when it comes to writing code, you’re often forced to use VB or a derivative, which aren’t ideal tools for manipulating text. But invoking your favorite bit of Perl, simply and transparently, deep within the internals of Excel, Word, VB and the like is now much easier, thanks to ActiveState’s PerlCOM and PerlCtrl, parts of their commercial Perl Development Kit available at http://www.activestate.com.

This article describes a scenario in which a complete Perl solution (using an external Perl script to automate Office) wasn’t appropriate, but a hybrid Perl/non-Perl approach was, and how PerlCOM made that hybrid solution almost trivially simple.

Warning

There is VB code in the following example. It’s the subject of the article, so I can’t really skip it. You don’t need to know VB in order to read the examples; they’re fairly simple, and as long as you get the gist of what the VB code does, ...

Get Computer Science & Perl Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.