SPUG: Win32::OLE help?

Marc M. Adkins Perl at Doorways.org
Fri Jun 17 16:13:07 PDT 2005

> I'd very much like to learn how to use this technology from Perl, if
> it can really help me. Is there a decent tutorial somewhere?

I've personally gotten a lot of mileage out of Win32::OLE over the 
years.  I've used it to disassemble Power Point documents, create Excel 
spreadsheets, convert Word documents to HTML in batch mode, open IE from 
an HTTP::Daemon server to point to the server itself, and scan Outlook 
messages sent by programs for specific error strings and then open the 
messages.  And other stuff I don't remember right at the moment.

But a good tutorial...that's a different matter.  Seems like the 
Win32::OLE documentation refers to a TPJ article, but perhaps I saw that 
reference elsewhere.

The main problem with generating a tutorial for this topic is that the 
first largish chunk of it ends up being an explanation of what COM/OLE 
is and how to get all of the data about the application you want to 
manipulate.  The actual use of Win32::OLE is kind of anti-climactic. 
Once you know what properties to reference and what calls to make for a 
particular application the Win32::OLE package just works.

Most of what I've figured out comes from (a) spending quality time 
writing COM code in VB and C++ some years back and (b) the OLE Browser 
that comes with ActiveState Perl.  The former is just good background. 
It's helpful to have a clue what COM actually is, though I don't know 
that it is necessary.

The latter is actually what I've used to figure out all of the 
Win32::OLE code that I've written (with occasional visits to Microsoft's 
web site to clarify particular calls).  It's trial and error though, 
somewhat of a black art, takes a bit of time.  There are these places 
where one just needs a magic cookie and they're not always obvious.

The thing about the OLE Browser is that it shows what is actually 
available.  COM interfaces are accessible so it just queries them.  If 
it's available, you see it.  Just without any useful documentation.


More information about the spug-list mailing list