Geting can't call range for one particular method. Below is my code. -----------------
#require 5.008; use diagnostics; use warnings; use strict; use Win32::OLE; use Win32::OLE::Variant; use Win32::OLE::Const 'Microsoft Excel'; main(); sub main { my $cnt=1; my $ex = Win32::OLE->new('Excel.Application'); my $workbook1= $ex->Workbooks->Open('D:\\TradedBondFiles\\IN\\Trad +edBondFile.xls',3) || die "Something went wrong: " ; my $sheet1= $workbook1->WorkSheets(1); our $sheet2=$workbook1->WorkSheets(2); $workbook1->Worksheets(1)->Range("B3:B1000")->Copy; $workbook1->Worksheets(2)->Range("A1:A1000")->PasteSpecial; $workbook1->Worksheets(1)->Range("J3:J1000")->Copy; $workbook1->Worksheets(2)->Range("B1:B1000")->PasteSpecial; $workbook1->Worksheets(1)->Range("G3:G1000")->Copy; $workbook1->Worksheets(2)->Range("C1:C1000")->PasteSpecial; $workbook1->Worksheets(1)->Range("K3:K1000")->Copy; $workbook1->Worksheets(2)->Range("D1:D1000")->PasteSpecial; $workbook1->Worksheets(1)->Range("M3:M1000")->Copy; $workbook1->Worksheets(2)->Range("E1:E1000")->PasteSpecial; $workbook1->Worksheets(1)->Range("H3:H1000")->Copy; $workbook1->Worksheets(2)->Range("F1:F1000")->PasteSpecial; $workbook1->Worksheets(1)->Range("F3:F1000")->Copy; $workbook1->Worksheets(2)->Range("G1:G1000")->PasteSpecial; $workbook1->Worksheets(1)->Range("A3:A1000")->Copy; $workbook1->Worksheets(2)->Range("H1:H1000")->PasteSpecial; $sheet2->Range("C1:C1000")->{NumberFormat} = "dd-mon-yy"; $ex-> {DisplayAlerts} = 0; $sheet2->SaveAs ({Filename => "D:\\TradedBondFiles\\OUT\\TradedBon +dFile.csv",FileFormat =>xlCSV}); $cnt = $cnt+1; $workbook1->Close(); $ex->Quit(); }

In reply to Can't call method "Range" on an undefined value at line 16 by abhishek1990

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.