2016-07-22 82 views
0

我有用於更新Word文檔的正在運行的PERL腳本。 PERL腳本編碼與MS Office 2003或2007一起使用。 我試圖通過BF進行更新的計算機上安裝了Office 2003,安裝了適當的模板,宏安全設置已更新。使用PERL和Win32處理Word文檔:: OLE在命令行上工作,但不能從BuildForge中運行步驟

當我運行確切的命令,我想讓BF在命令行上使用時,它按預期工作。 當我通過BF步驟運行時,我得到「***無法在\ servername \ projectname \ bin \ updateVer.pl第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: [email protected]\n", Win32::OLE->LastError() if ([email protected] || ! $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 \服務器\項目名稱\ BIN \ updateVer.pl -path「C:\ BuildForgeBuilds \ BFProjectName \ BFProjectName_0177 \ MyDocument.doc「-bookmarkName REV_Baseline -bookmarkValue My_Baseline_10.20.30

我可以得到一些方向來說服BF可以打開我的工作文檔嗎? 謝謝!

+0

它被稱爲*「Perl」* – Borodin

+0

對不起@鮑羅丁,我不知道你的評論會如何幫助我。我們使用ccperl,因爲我們已經在我們所有的機器上安裝了cc。 – ChrisM

+0

這不是你的問題的答案;這就是爲什麼它是一個評論。它應該可以幫助你正確拼寫Perl語言的名字。我懷疑你是否會寫JAVA或PYTHON,或者確實是MS OFFICE? – Borodin

回答

0

當我從運行作業的計算機上的模板中刪除「歸檔」位後,BF成功運行其作業。

有趣我可以直接在服務器上運行它,並在模板上設置'歸檔'位。但是,嘿,我不再陷入這個問題。

感謝任何人閱讀我的問題,甚至考慮可能是什麼問題。

相關問題