Need Help Protecting Word Doc via Win32::OLE

T

Tom Welch

Does anyonw know how to apply Word document protection via win32::eek: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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,772
Messages
2,569,593
Members
45,105
Latest member
sheetaldubay7750ync
Top