T
Tom Welch
Does anyonw know how to apply Word document protection via win32:
le
? I've been using Win32::OLE to dynamically build a Word document
Form from content in a database. I've been trying to protect the
document as the last step before saving but so far without success. I
don't get any errors but the newly saved Word file opens unprotected.
Here's the code I'm using.
use Win32::OLE qw(in);
my $Word = Win32::OLE->new('Word.Application', 'Quit');
$inFile='test.doc';
$outFile='test_temp.doc';
my $Doc = $Word->Documents->Open($inFile);
.... misc steps to add form fields ...
# -- protect document
$Doc->Protect({ Type=>wdAllowOnlyFormFields, NoReset=>True,
Password=>"mypw",});
# -- save under new name
unlink $outFile if -f $outFile;
$Doc->SaveAs($outFile);
$Doc->Close;
Thanks,
Tom Welch
? I've been using Win32::OLE to dynamically build a Word document
Form from content in a database. I've been trying to protect the
document as the last step before saving but so far without success. I
don't get any errors but the newly saved Word file opens unprotected.
Here's the code I'm using.
use Win32::OLE qw(in);
my $Word = Win32::OLE->new('Word.Application', 'Quit');
$inFile='test.doc';
$outFile='test_temp.doc';
my $Doc = $Word->Documents->Open($inFile);
.... misc steps to add form fields ...
# -- protect document
$Doc->Protect({ Type=>wdAllowOnlyFormFields, NoReset=>True,
Password=>"mypw",});
# -- save under new name
unlink $outFile if -f $outFile;
$Doc->SaveAs($outFile);
$Doc->Close;
Thanks,
Tom Welch