Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Need Help Protecting Word Doc via Win32::OLE

Reply
Thread Tools

Need Help Protecting Word Doc via Win32::OLE

 
 
Tom Welch
Guest
Posts: n/a
 
      05-26-2004
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
.pdf doc to word doc PWB Computer Support 14 09-19-2008 10:41 PM
XML from Word -- formerly Create pdf from existing Word doc (asp.net) Sharon ASP .Net 0 07-27-2005 02:07 AM
String[] files = {"a.doc, b.doc"}; VERSUS String[] files = new String[] {"a.doc, b.doc"}; Matt Java 3 09-17-2004 10:28 PM
opening a word doc in word not browser Stephen Witter ASP .Net 0 05-18-2004 02:48 AM
Parsing MS Word client doc into server-side doc... John Wallace ASP .Net 0 07-22-2003 06:49 PM



Advertisments