You know, if you check the return value from the Delete method and LastError(), you do get the same message that Excel displays when you try to delete the last sheet, as demonstrated:
use strict; use warnings; use Win32::OLE; my $xl = Win32::OLE->new('Excel.Application'); $xl->{Visible} = 1; my $nShtsOld = $xl->{SheetsInNewWorkbook}; $xl->{SheetsInNewWorkbook} = 1; my $wb = $xl->Workbooks->Add; $xl->{SheetsInNewWorkbook} = $nShtsOld; my $delResp = $wb->Sheets(1)->Delete; unless (defined $delResp) { print "delete failed: ".Win32::OLE::LastError()."\n"; } else { print "sucessfully deleted sheet #1\n"; }
I found this to be helpful, anyway,
Additionally, if you have displayAlerts on, $delResp will = 1 if user pressed delete, 0 if cancel
Larry
In reply to Re: RFC Tutorial - Deleting Excel Rows, Columns and Sheets
by lkench
in thread RFC Tutorial - Deleting Excel Rows, Columns and Sheets
by davies
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |