2013-05-29 82 views

回答

0

一種方法是嘗試使用虛擬密碼打開文檔。

以下是我試過的方法。

my $Word = Win32::OLE->new('Word.Application'); 

if(!$Word){ 
    # Word can't be opened, exit or return false 
} 

my $Doc; 
eval{$Doc = $Word->Documents->Open("Path to your doc",undef,undef,undef,"thisIsPassword");}; 
if([email protected]){ 
    # Document opening failed, exit or return false 
} 
if(!$Doc){ 
    # File doesn't exists, exit or return false 
} 

my $var = Win32::OLE->LastError() ; 
if($var){ 
    # File may be password protected, exit or return false 
} 
unless ($Doc eq '') { 
    # Do whatever... 
} 
相關問題