jinhuang1992 has asked for the wisdom of the Perl Monks concerning the following question:

When a spreadsheet is open, I want to write a PERL with OLE program to close the spreadsheet automatically. Can you show me how? Thanks.

Replies are listed 'Best First'.
Re: EXCEL with PERL
by VSarkiss (Monsignor) on Aug 12, 2004 at 15:48 UTC
Re: EXCEL with PERL
by guha (Priest) on Aug 12, 2004 at 16:24 UTC

    If you don't care about saving the open spreadsheets, this snippet will brutally close down all open instances of Excel.

    #!perl -w use strict; use Win32::OLE; my $ex = Win32::OLE->GetActiveObject('Excel.Application') or die "No a +ctive objects around\n"; $ex->{DisplayAlerts} = 0; $ex->Quit;

    Another way to do it, at least on WinXP would be the system command.

    taskkill /f /im EXCEL.EXE