Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Closing Excel

Reply
Thread Tools

Closing Excel

 
 
jim simpson
Guest
Posts: n/a
 
      01-16-2005
I need to determine if Excel is running and if so close it. Can this be done
with a Perl script and can someone suggest an approach to do it.

Thanks,

Jim


 
Reply With Quote
 
 
 
 
A. Sinan Unur
Guest
Posts: n/a
 
      01-16-2005
In article <QRxGd.77526$Jk5.18511@lakeread01> posted on Sun, 16 Jan 2005
12:52:12 -0500, jim simpson wrote:

> I need to determine if Excel is running and if so close it. Can this be done
> with a Perl script and can someone suggest an approach to do it.


See http://search.cpan.org/dist/Win32-OLE/

--
A. Sinan Unur
http://www.velocityreviews.com/forums/(E-Mail Removed)d -- remove invalid and
reverse each component for email address.

 
Reply With Quote
 
 
 
 
Jay Tilton
Guest
Posts: n/a
 
      01-16-2005
"jim simpson" <(E-Mail Removed)> wrote:

: I need to determine if Excel is running and if so close it. Can this be done
: with a Perl script and can someone suggest an approach to do it.

#!perl
use warnings;
use strict;
use Win32::OLE;

while(
my $excel =
Win32::OLE ->GetActiveObject('Excel.Application')
) {
$excel ->Quit
}

 
Reply With Quote
 
Matt Garrish
Guest
Posts: n/a
 
      01-17-2005

"Jay Tilton" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "jim simpson" <(E-Mail Removed)> wrote:
>
> : I need to determine if Excel is running and if so close it. Can this be
> done
> : with a Perl script and can someone suggest an approach to do it.
>
> #!perl
> use warnings;
> use strict;
> use Win32::OLE;
>
> while(
> my $excel =
> Win32::OLE ->GetActiveObject('Excel.Application')
> ) {
> $excel ->Quit
> }
>


I'd add the warning that the user may not appreciate you closing their
applications. It's generally better practice to warn them that the script
shouldn't be run while Excel (or whatever) is open and bail out.

Matt


 
Reply With Quote
 
Bob Walton
Guest
Posts: n/a
 
      01-17-2005
Jay Tilton wrote:

> "jim simpson" <(E-Mail Removed)> wrote:
>
> : I need to determine if Excel is running and if so close it. Can this be done
> : with a Perl script and can someone suggest an approach to do it.
>
> #!perl
> use warnings;
> use strict;
> use Win32::OLE;
>
> while(
> my $excel =
> Win32::OLE ->GetActiveObject('Excel.Application')
> ) {
> $excel ->Quit
> }
>


One might want to include a statement like:

$excel->Application->{DisplayAlerts}='False';

before the ->Quit call if one wishes to ensure Excel actually
shuts down without user intervention (otherwise, one may get a
prompt about saving modified worksheets). This might just apply
to recent versions of Excel (as I recall, a different sequence
was required with Excel 97 and earlier??).

--
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl
 
Reply With Quote
 
jim simpson
Guest
Posts: n/a
 
      01-17-2005
Thanks to all who responded to my Post.

It works great, of course, and I do need Bob's addition.

Jim


"Jay Tilton" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "jim simpson" <(E-Mail Removed)> wrote:
>
> : I need to determine if Excel is running and if so close it. Can this be

done
> : with a Perl script and can someone suggest an approach to do it.
>
> #!perl
> use warnings;
> use strict;
> use Win32::OLE;
>
> while(
> my $excel =
> Win32::OLE ->GetActiveObject('Excel.Application')
> ) {
> $excel ->Quit
> }
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with Excel reports ::::Excel 2003 Migration To Excel 2007 =?Utf-8?B?c2hhc2hhbmsga3Vsa2Fybmk=?= ASP .Net 15 10-24-2007 01:34 PM
Closing popup window when closing parent window? =?Utf-8?B?Vk1J?= ASP .Net 3 02-15-2007 08:29 AM
Closing the doors 15 minutes before closing. doofus Computer Support 12 06-11-2005 08:20 AM
closing excel Mark ASP .Net 2 04-14-2004 07:56 AM
Closing child window WITHOUT closing parent thomas Javascript 0 10-23-2003 04:10 PM



Advertisments