I think the problem is that Selection is not property of Excel, rather workbook or worksheet. I tried to elaborate a bit -- this works for me:
use Win32::OLE; use Win32::OLE::Const 'Microsoft Excel'; my $excel = Win32::OLE->CreateObject('Excel.Application') or die $!; $excel->{Visible} = 1; my $workbook = $excel->Workbooks->Add; my $worksheet = $workbook->ActiveSheet; $worksheet->Range('A1:B2')->{Value} = [[1,2],[2,4]]; $worksheet->Range('A1:B2')->AutoFill({ Destination => $worksheet->Range('A1:B17'), Type => xlFillDefault, });
I am creating new workbook in example above, but you can open one as you did and access individual worksheets with Sheets property:
my $ws2 = $workbook->Sheets('SheetName'); $ws2->...

Hope this helps

-- Roman


In reply to Re^3: Win32::OLE Excel AutoFill not working by bobr
in thread Win32::OLE Excel AutoFill not working by DaveTheMan

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.