【问题标题】:Trying to understand why Perl Win32 OLE Excel Server threw an exception试图理解为什么 Perl Win32 OLE Excel Server 会抛出异常
【发布时间】:2013-03-28 16:21:19
【问题描述】:

试图了解和诊断我在 MS server 2008 上的 Excel 设置有什么问题。请参阅下面的 MWE。这在我的 Win 笔记本电脑上运行良好,但在服务器上不是很好。从干净的登录开始,它第一次运行正常,但随后的运行失败并显示错误文本:

Win32::OLE(0.1709) error 0x80010105: "The server threw an exception"
    in PROPERTYPUT "DisplayAlerts" at mwe.pl line 20

第一次运行将 excel.exe 留在任务管理器中。我想第二次运行是试图重新连接到这个现有实例但失败了。请问我怎么知道出了什么问题?

或者,我如何在脚本完成后终止由 Win32::OLE 启动的 Excel 进程,以便重新运行启动一个新实例?

我的 MWE:

use strict;
use warnings;

use Win32::OLE qw(in with);
use Win32::OLE::Const 'Microsoft Excel';

$Win32::OLE::Warn = 3; # Die on Errors.

# use existing instance if Excel is already running
my $Excel;
eval {$Excel = Win32::OLE->GetActiveObject('Excel.Application')};
die "Excel not installed" if $@;

unless (defined $Excel) {
   print "another\n!";
   $Excel = Win32::OLE->new('Excel.Application', sub {$_[0]->Quit;})
            or die "Oops, cannot start Excel";
}

$Excel->{DisplayAlerts}=0;

$Excel->Quit();
undef $Excel;

【问题讨论】:

    标签: perl excel exception win32ole


    【解决方案1】:

    你能用引号试试 $Excel->{'DisplayAlerts'} = 0 吗?我就是这样使用它并且它有效。我想所有的引用都是这样写的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-04-28
      • 2013-09-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-12
      相关资源
      最近更新 更多