Calling macro from another workbook using perl

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Anuja T
    New Member
    • Jan 2012
    • 12

    Calling macro from another workbook using perl

    Hi,

    I am dealing with running macros through perl.
    i have following script to do the same which is working fine.Now what i have to do is to make one .xlsm (macro-enabled file)which will contain all the needed macros.
    and i need to call that macros from another .xlsx file.
    I am trying to give path in that RUN() rather than macro name but it is not working.
    Can anybody tell me,how to do this?


    Code:
    #!/usr/bin/perl
    use strict;
    use Win32::OLE qw(in with);
    use Win32::OLE::Const;
    use Win32::OLE::Const 'Microsoft Excel';
    $Win32::OLE::Warn = 3;
    
    
    my $filename = 'F:\perl\report.xlsx';
    
    my $Excel = Win32::OLE->GetActiveObject('Excel.Application') 
    || Win32::OLE->new('Excel.Application', 'Quit'); 
    
    my $Book = $Excel->Workbooks->Open( $filename );
    
    $Excel->Run("Deletebrows"); # This is macro name
    $Excel->Run("FillEmptyCellWithZero"); # This is macroname
    $Book->Close;
Working...