in reply to Running an excel macro from Perl
I patched the following together from the examples in the Activestate documentation in the section "Using OLE with Perl", under the subheading "How do I run a Macro in Microsoft Excel". It works quite well.
This will only work if you run it on a Windows system with Excel installed
use strict; use Win32::OLE qw(in with); use Win32::OLE::Const 'Microsoft Excel'; my $filename = 'book1.xls'; my $Excel = Win32::OLE->GetActiveObject('Excel.Application')|| Win32:: +OLE->new('Excel.Application', 'Quit'); # use the Excel application i +f it's open, otherwise open new my $Book = $Excel->Workbooks->Open( $filename ); # open the file $Excel->Run("macro_name"); $Book->Save; #optional - save any changes made by the macro $Book->Close;
|
|---|