in reply to Copy paste rows in excel

but the solution given here doesnt seems to work
That is a pretty vague statement. You will learn that you get much better answers if your question is more precise.

Now we can only guess.

<crystal ball mode = ON>

Did you use strict; use warnings;? If you did you should have gotten an error for $Sheet->copy($range1); because $Sheet is not the same variable as $sheet.

<crystal ball mode = OFF>

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

Replies are listed 'Best First'.
Re^2: Copy paste rows in excel
by Ankit.11nov (Acolyte) on Jul 21, 2009 at 07:06 UTC
    That was just a typing mistake here. I was using use strict & use warnings in my program.
    use strict; use warnings; use Win32::OLE; #get an existing app or create a new one my $ex = Win32::OLE->GetActiveObject('Excel.Application') || Win32::OL +E->new('Excel.Application' , 'Quit'); $ex->{DisplayAlerts}=0; #open workbook my $book = $ex->Workbooks->open('D:\Profiles\in2228c\Desktop\TIN\Cr_an +alysis.xls'); #Activating worksheet my $sheet = $book->Worksheets("Sheet1"); my $range1=$sheet->range('A1'); $sheet->copy($range1); my $range2=$sheet->range('A2'); $range2=$sheet->paste($range2); $book->SaveAs('D:\Profiles\in2228c\Desktop\TIN\Cr_analysis.xls');