O'Reilly logo

Computer Science & Perl Programming by Jon Orwant

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required