ff has asked for the wisdom of the Perl Monks concerning the following question:
# check if Excel exists my $x = Win32::OLE->GetActiveObject('Excel.Application'); if ($@) { warn "Excel not Installed.\n"; die "Excel not Installed.\n"; } # start Excel program, die if unable to unless (defined $x) { $x = Win32::OLE->new('Excel.Application', sub { $_[0]->Quit; } ) # and # sleep 1 or warn "Cannot start Excel.\n" and die "Cannot start Excel.\n"; } $x->{DisplayAlerts}=0; # no messages from Excel
When Excel had NOT been running for some time, the above produced an error message of:
Win32::OLE(0.1502) error 0x80010105: "The server threw an exception" in PROPERTYPUT "DisplayAlerts" at /PerlApp/xls_subs.pl line 110
which corresponds to the "$x->{DisplayAlerts}" line above. However, running the same chunk of code again, changing nothing, raised no exceptions. And so it seems that I'm getting hung up by an initialization process for Excel, that, once loaded in RAM, doesn't affect me again. Is uncommenting these lines
the right approach or is there a way to wait until Excel is good and ready before proceding? Thanks.# and # sleep 1
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Initialization process exceptions with Excel; Win32::OLE
by ff (Hermit) on Oct 24, 2003 at 03:49 UTC |