我有功能的PERL脚本,用于更新Word文档。PERL脚本编码为可与MS Office 2003或2007一起使用。我尝试通过BF进行更新的计算机上安装了Office 2003,安装了适当的模板,宏安全性设置也已更新。
当我在命令行上运行我希望BF使用的确切命令时,它可以正常工作。当我通过BF步骤运行它时,我得到“* Unable to open doc at Perl line 94”(行号是\servername\projectname\bin\updateVer.pl脚本中的croak )。
脚本看起来就像这样:
# enable Sanity checking and make the variable names meaningful
use strict;
use warnings;
use English;
use Win32::OLE;
# Gain access to MS Word 'wd' constants
use Win32::OLE::Const ('Microsoft Word');
use FindBin qw($RealDir);
use lib ($RealDir, "$RealDir/..", "$RealDir/../lib");
# include the common and log utilities
use SCCM::Common;
use SCCM::Logs;
# use command line inputs
use Getopt::Long qw(:config auto_abbrev permute ignore_case pass_through);
# set up logs and process logfile options
logOptions(qw(-log now));
my $bookmark_update_result = "";
my $update_ref_result = "";
# Get input from user
my $path;
my $bookmarkName;
my $bookmarkValue;
my $Word;
my $newWord = 0;
GetOptions("path=s" => \$path,
"bookmarkName=s" => \$bookmarkName,
"bookmarkValue=s" => \$bookmarkValue);
unless ( defined($path) )
{ croakf "%[Fail] Path and filename of SVD are required\n"; }
unless ( defined($bookmarkName) && defined($bookmarkValue) )
{ croakf "%[Fail] bookmarkName and bookmarkValue parameters are both required.\n"; }
# Start Word in a safer way, checking to see if user has it open first.
eval
{
$Word = Win32::OLE->GetActiveObject('Word.Application');
if (! $Word)
{
$newWord = 1;
$Word = Win32::OLE->new('Word.Application', 'Quit');
}
};
croakf "%[Fail] -- unable to start Word Engine: $@\n", Win32::OLE->LastError() if ($@ || ! $Word);
my $dispAlerts = $Word->{'DisplayAlerts'};
$Word->{'DisplayAlerts'} = wdAlertsNone;
if ($newWord)
{
$Word->{'Visible'} = 0;
}
my $doc = $Word->Documents->Open($path) or
croakf ("%[Fail] Unable to open doc ", Win32::OLE->LastError() );脚本的调用方式如下:"C:\BuildForgeBuilds\BFProjectName\BFProjectName_0177\MyDocument.doc“\servername\projectname\bin\updateVer.pl -path ccperl -bookmarkValue My_Baseline_10.20.30
我可以得到一些指示来说服BF可以打开我的工作文档吗?谢谢!
发布于 2016-07-26 02:41:03
原来,在我从运行作业的机器上的模板中删除了'Archive‘位之后,BF能够成功地运行它的作业。
有趣的是,我可以直接在服务器上运行它,并在模板上设置了'Archive‘位。但是,嘿,我不再被困在这个问题上了。
感谢任何读过我的问题的人,甚至是考虑过问题的人。
https://stackoverflow.com/questions/38534668
复制相似问题