2013-03-28 50 views
0

试图了解和诊断MS服务器2008上Excel设置的问题。请参阅下面的MWE。这在我的Win笔记本电脑上正常工作,但在服务器上不太好。从清洁登录它运行正常第一次,但随后的运行失败,错误文本:试图了解为什么Perl Win32 OLE Excel Server引发异常

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 [email protected]; 

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; 

回答

0

你可以尝试用$ Excel中 - > { 'DisplayAlerts'} = 0引号?我用这种方式,它的工作原理。我想所有的参考都是这样做的。

相关问题