Closing Excel

Discussion in 'Perl Misc' started by jim simpson, Jan 16, 2005.

  1. jim simpson

    jim simpson Guest

    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
     
    jim simpson, Jan 16, 2005
    #1
    1. Advertising

  2. 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
    d -- remove invalid and
    reverse each component for email address.
     
    A. Sinan Unur, Jan 16, 2005
    #2
    1. Advertising

  3. jim simpson

    Jay Tilton Guest

    "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.

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

    while(
    my $excel =
    Win32::OLE ->GetActiveObject('Excel.Application')
    ) {
    $excel ->Quit
    }
     
    Jay Tilton, Jan 16, 2005
    #3
  4. jim simpson

    Matt Garrish Guest

    "Jay Tilton" <> wrote in message
    news:...
    > "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.
    >
    > #!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
     
    Matt Garrish, Jan 17, 2005
    #4
  5. jim simpson

    Bob Walton Guest

    Jay Tilton wrote:

    > "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.
    >
    > #!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
     
    Bob Walton, Jan 17, 2005
    #5
  6. jim simpson

    jim simpson Guest

    Thanks to all who responded to my Post.

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

    Jim


    "Jay Tilton" <> wrote in message
    news:...
    > "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.
    >
    > #!perl
    > use warnings;
    > use strict;
    > use Win32::OLE;
    >
    > while(
    > my $excel =
    > Win32::OLE ->GetActiveObject('Excel.Application')
    > ) {
    > $excel ->Quit
    > }
    >
     
    jim simpson, Jan 17, 2005
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mark

    closing excel

    Mark, Apr 13, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    2,012
  2. Winshent
    Replies:
    0
    Views:
    1,985
    Winshent
    Nov 3, 2004
  3. =?Utf-8?B?Vk1J?=

    Closing popup window when closing parent window?

    =?Utf-8?B?Vk1J?=, Feb 14, 2007, in forum: ASP .Net
    Replies:
    3
    Views:
    674
    Thomas Hansen
    Feb 15, 2007
  4. =?Utf-8?B?c2hhc2hhbmsga3Vsa2Fybmk=?=

    Problem with Excel reports ::::Excel 2003 Migration To Excel 2007

    =?Utf-8?B?c2hhc2hhbmsga3Vsa2Fybmk=?=, Oct 5, 2007, in forum: ASP .Net
    Replies:
    15
    Views:
    1,594
    =?Utf-8?B?c2hhc2hhbmsga3Vsa2Fybmk=?=
    Oct 24, 2007
  5. thomas
    Replies:
    0
    Views:
    249
    thomas
    Oct 23, 2003
Loading...

Share This Page