Automating Word with Perl

I used Word to generate the Word and PDF formats of my resume. The master version of the resume is in XML. Converting the XML to HTML is accomplished using XSLT as described in another article. For some reason, most recruiters want Word versions of resumes. Word is also pretty good at printing nice output that looks like the web version. I used to manually import the HTML file into Word, make some tweaks, save the Word format file, and print to PostScript and PDF.

One of the features of Microsoft Word is that it can be automated using COM. COM is Microsoft's way of calling remote objects from different languages. Visual Basic is the script language used most often on Windows. I come from the Unix world and prefer to use Perl. ActiveState's ActivePerl native Windows distribution includes COM interface modules. Unfortunately, I couldn't find the COM interface modules for the Cygwin port of Perl.

The COM interface to Word is described on Microsoft's MSDN developer web site. The interface has methods for finding the Word application, opening a file, changing the document, saving the file as different formats, and printing to different printers.

My Perl script: opens the HTML file, changes the heading font, changes the hyperlink style, changes the margins, saves it as a .doc file, saves as RTF file, and prints to a PostScript file.