title: How do I use Perl and Excel OLE to copy a worksheet to a new or existing workbook?
body: <p>I have tried using the following Perl code, but the worksheet does not copy (nor move) and no error message is returned.  Thanks in advance for your ideas.</p>
  
  <pre><code>#!/usr/bin/perl -w
  use strict;
  use warnings;
  use OLE;
  use Win32::OLE::Const 'Microsoft Excel';
  
  my $Excel = CreateObject OLE "Excel.Application";
  my $Book2 = $Excel-&gt;Workbooks-&gt;Add();
  my $Book3 = $Excel-&gt;Workbooks-&gt;Open("C:\\temp\\test.xlsm");
  my $Sheet3 = $Book3-&gt;Worksheets(1);
  $Sheet3-&gt;Select;
  $Sheet3-&gt;Move("Before" =&gt; $Book2-&gt;Worksheets(1));
  $Book3-&gt;Close(0);
  $Book2-&gt;SaveAs({Filename =&gt;"C:\\temp\\new.xlsm",FileFormat =&gt; xlOpenXMLWorkbookMacroEnabled}); 
  $Book2-&gt;Close();
  $Excel -&gt; Quit();
  </code></pre>