title: how to run VBA macro from perl code
body: <p>I am new to perl &amp; i am trying to write a module which would run a excel macro on a already open excel sheet. there is a code sniplet that describes how to run a macro from another excel sheet but i want the macro code as a subroutine in the same file. How to implement that? Can any one help?</p>
  
  <pre><code>use strict;
  use warnings;
  use Win32::OLE;
  my $excel= Win32::OLE-&gt;new('Excel.Application')or die "Could not create Excel.Application!\n;
  $excel-&gt;Workbooks-&gt;open( 'C:\Users\Me\Documents\Book1.xlsx' );
  $excel-&gt;run( 'Book1!Macro1' );
  
  # Here i want that Macro1 as sub in this file itself &amp; not from book1
  
  $excel-&gt;quit;
  </code></pre>