sort the rows so that all the empty rows are at the end and the last row command would do the trick.
just a thought Later, Matt -----Original Message----- From: Beckett Richard-qswi266 [mailto:[EMAIL PROTECTED] Sent: Friday, July 11, 2003 5:53 AM To: perl-win32-users Subject: RE: Excel and empty rows. Oops! Typos. $EmptyRow and $LastRow, should both be the same var. i.e.... > Guys, > > I have sorted out what the problems are, I just don't know > how to address > them. > > I am trying to find the first empty row in a spreadsheet. > > If I use this suggestion: > > my $EmptyRow = $sheet->UsedRange->rows->count; > $EmptyRow++; > > This points $EmptyRow to the first empty row of the > spreadsheet, UNLESS the > spreadsheet is totally empty. Then, the first line returns a > 1, and so I > write into row 2 by mistake. > > > This suggestion: > > my $EmptyRow = $sheet->UsedRange->Find({What=>"*", > SearchDirection=>xlPrevious, > SearchOrder=>xlByRows})->{Row}; > $EmptyRow++; > > Will again point $EmptyRow at the first empty row, UNLESS the > spreadsheet is > totally empty, when it causes the script to die with... > > Can't use an undefined value as a HASH reference at D:\PR.pl > line 43, <FILE> > line 167. > Win32::OLE(0.1502) error 0x80010108: "The object invoked has > disconnected > from its clients" in METHOD/PROPERTYGET "" at D:\PR.pl line 119 > > > So, either I need to be able to test for an empty > spreadsheet, or I need to > catch the error generated, and set the value of $EmptyRow to 0. > > Unfortunately, both options are beyond me. > > Thanks. > > R. > > PS. As an aside, why can't I do this? > > my $EmptyRow++ = $sheet->UsedRange->Find({What=>"*", > SearchDirection=>xlPrevious, > SearchOrder=>xlByRows})->{Row}; _______________________________________________ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs _______________________________________________ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs