我有用于更新 Word 文档的正常运行的 PERL 脚本。PERL 脚本被编码为与 MS Office 2003 或 2007 一起使用。我试图通过 BF 进行更新的机器已打开 Office 2003,安装了适当的模板,宏安全设置已更新。
当我运行我希望 BF 在命令行上使用的确切命令时,它按预期工作。当我通过 BF 步骤运行它时,我得到“*** Unable to open doc at \servername\projectname\bin\updateVer.pl line 94”(行号是 Perl 脚本中的呱呱声)。
脚本看起来像这样:
# 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() );
该脚本的调用方式如下: ccperl \servername\projectname\bin\updateVer.pl -path "C:\BuildForgeBuilds\BFProjectName\BFProjectName_0177\MyDocument.doc" -bookmarkName REV_Baseline -bookmarkValue My_Baseline_10.20.30
我可以得到一些指导来说服 BF 打开我的工作文档是可以的吗?谢谢!