title: Using Win32::OLE to execute macro in Access 2007
body: <p>Currently I am trying to execute a macro in Microsoft Access through Perl OLE</p>
  
  <p>I am wondering how to properly make the call to run a macro. I have tried</p>
  
  <p>1) <code>$oDatabase -&gt; DoCmd.RunMacro("Macro1");</code><br>
  2) <code>$oDatabase -&gt; DoCmd -&gt; RunMacro("Macro1");</code></p>
  
  <p>But they throw me "Can't call method "DoCmd" on an undefined value" or "useless use of concatentation"</p>
  
  <p>Is this even possible to execute a DoCmd through Win::32 OLE? Any help would be greatly appreciated.</p>
  
  <p>Here is a complete code. It tries to look for the current Microsoft Access that is opened.</p>
  
  <pre><code>use strict; 
  use warnings; 
  use Win32::OLE;
  
  my $oAccess;
  my $oDatabase;
  
  my $filename = "C:\\Sample.accdb"; 
  $oAccess = Win32::OLE-&gt;GetActiveObject('Access.Application');
  
  $oDatabase = $oAccess-&gt;OpenCurrentDatabase($filename);
  $oDatabase -&gt; DoCmd.RunMacro("Macro1");
  </code></pre>