newWin32::OLE->new ( progid , [ destructor ])
Creates a new automation object. This method always creates
a new instance of the server, even if a previous instance of
the server is running. If the object cannot be created, progid , the program identifier (ProgID), is a string that uniquely identifies an automation object. progid is used to look up the object's class ID (CLSID), which is stored in the registry.
The second, optional argument to the
Here is what Notice that we're supplying Excel.Application as the ProgID. Excel supports several different automation objects, including an Application object, WorkBook objects, and several more. You don't necessarily have to create the top-level object (Application, in this case) when dealing with automation objects (this is determined by the automation server). In Excel's case, we could have directly created a WorkSheet object (e.g., Excel.Sheet) or a Chart object, for example.# Quit is the OLE-defined destructor method $x1 = Win32::OLE->new("Excel.Application", 'Quit'); # The object reference is the first argument ($_[0]) passed to new. # The code reference will undef it to destroy the object. $x2 = Win32::OLE->new("Excel.Application", sub{undef $_[0];}) |
|