in reply to Re^5: Can't Find my way in Excel
in thread Can't Find my way in Excel

My apologies for bad transcription. It is hard moving from computer to computer, copying and typing. I was hoping it was obvious what I was trying to do. The old way was what is shown above. The new way I am trying to find is replacing the search by row and cell and just use a Find. So the new code would be

use strict; use Win32::OLE; use Win32::OLE::Const 'Microsoft Excel'; my $Excel = Win32::OLE->new('Excel.Application','Quit') or die "Cannot + open Excel\n"; my $Book = $Excel->workbooks->Open(FileName => "c:/foo.xlsx", ReadOnly + => 1) or die "Cannot open Spreadsheet\n"; my $num_sheets = $Book->Sheets->Count; for my $sheet_num ( 1 .. $num_sheets ) { my $Sheet = $Book->worksheets( $sheet_num ); my $max_col = $Sheet->UsedRange->SpecialCells( xlCellTypeLastCell +)->Column; my $max_row = $Sheet->UsedRange->SpecialCells( xlCellTypeLastCell +)->Row; my $loc = $Sheet->UsedRange->Cells->Find({What=>"cabbage"}); }

Running in debug gives "Undefined subroutine &main:: called at (eval 14)D:/software/Perl/lib/ line 2, <$lh> line 7."

Running without debug gives "Can't use string ("") as a subroutine while "strict refs" in use at line 12, <$lh> line 7."

Again, I am trying to do my best to transcribe.