I havent ever used the excel OLE control, but I assume this will work (it does in other similar situations):
if(defined($sheet->Range("FRED"))) { # Cell is defined $sheet->Range("FRED")->{Value} = "foo"; } else { # Cell isnt defined, throw an error die("Cell \"FRED\" isn't defined!!"); } HTH - Matt ----- Original Message ----- From: <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, December 18, 2001 1:33 PM Subject: catching errors in OLE > Hi all, > > I'm trying to catch errors in a small excel driver script I've got. > Essentially, we parse a text file, take the values and stuff them into > named cells in a template spreadsheet, calculate, then save off the output > and loop to the next line in the text file. > > I have a problem when occasionally someone adds a new template xls to the > mix and forgets to name all the appropiate cells correctly. This results > in an error I seem unable (or too ignorant) to prevent... any help? > > Assume cell "FRED" is not defined. > > $sheet->Range("FRED")->{Value} = "foo" > > my script dies with the following: > > Can't use an undefined value as a HASH reference at E: > \denap\Perl\Excel\test.pl line 16. > > thanks, > -Tom > > _______________________________________________ > Perl-Win32-Users mailing list > [EMAIL PROTECTED] > http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users > _______________________________________________ Perl-Win32-Users mailing list [EMAIL PROTECTED] http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users