Need Help Protecting Word Doc via Win32::OLE

Discussion in 'Perl Misc' started by Tom Welch, May 26, 2004.

  1. Tom Welch

    Tom Welch Guest

    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
     
    Tom Welch, May 26, 2004
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matt
    Replies:
    3
    Views:
    555
    Tor Iver Wilhelmsen
    Sep 17, 2004
  2. Lance Hoffmeyer
    Replies:
    0
    Views:
    275
    Lance Hoffmeyer
    Nov 17, 2003
  3. Sylvia
    Replies:
    3
    Views:
    218
    John Bokma
    Sep 3, 2005
  4. mmm ppp
    Replies:
    0
    Views:
    168
    mmm ppp
    Oct 17, 2005
  5. deepakp
    Replies:
    1
    Views:
    785
    A. Sinan Unur
    Mar 3, 2006
Loading...

Share This Page