The OLE Automation extensions have been completely rewritten since the previous major version of Perl for Win32 (09x), resulting in a much cleaner syntax and added support for embedded objects (no more MkOLEx kludges!). OCX's are currently not supported, nor are VBX's.
OLE Automation objects are created using the CreateObject
method of
the OLE
module. The name of the class of OLE object to create is
supplied as the only argument. On success, the handle to the object is
returned, otherwise undef is returned.
To invoke methods or retrieve properties within the object, one then uses the standard Perl 5 O-O syntax. Arguments must be supplied in the correct order (usually in the order that they are listed in the documentation associated with a particular class. e.g. in the help files for Microsoft Excel).
Properties are also accessible via the perl object's hash structure. Since the return value of a function cannot be treated as an lvalue, the hash is the only means by which we can modify an object's properties.
If a method or a property returns an embedded OLE object, it can automatically be treated as a perl object itself. E.g.
...will invoke the method tell_old_war_stories
in grandad
which is
an embedded object within dad
, which itself is an embedded object
in $object
. The same goes for properties:
Simple as Pie!!
MkOLEx
,
and there is only one OLE
module for all OLE Automation objects
(i.e. no need to use the module OLE::Word_Basic
etc).