in reply to Perl Excel Help

I'm far from sure what you want, but I'll try anyway. However, let me start by stating my assumptions.

  • "Sheet" means a sheet and not a workbook (file).
  • "if" indicates that you are interested only in a boolean. A single occurrence or a hundred makes no difference. Once the value has been found you are not interested in anything else.
  • "the same" refers to "value" and means that you are interested in the value returned and not in any formula that gives rise to it. You also want a precise match and do not have problems with the accuracy of internal storage of binary representations of numbers.
  • "another" means precisely one other sheet which is known to you in advance, rather than any other sheet.
  • Both sheets are in the same workbook.
  • The following code works for me. If you make the assignments in lines 11 and 13 the same, you will get "Found" printed.

    use strict; use warnings; use Win32::OLE; my $xl = Win32::OLE->new('Excel.Application'); $xl->{SheetsInNewWorkbook} = 2; $xl->{Visible} = 1; my $wb = $xl->Workbooks->Add; my $cellSource = $wb->Sheets(1)->Cells(1,1); $cellSource->{Value} = 1; my $cellTarget = $wb->Sheets(2)->Cells(2,2); $cellTarget->{Value} = 2; my $addFound = $wb->Sheets(2)->Cells->Find({ What => $cellSource->{Value}, LookIn => -4163 #xlValues }); if ($addFound) {print "Found\n"} else {print "Not found\n"}

    Regards,

    John Davies