Capturing the password for form-protected documents

D

DDawson

Is there a way to capture the manually entered password so that I can assign
it to macros?

As you may already know, the document needs to be unprotected for the macros
to run. Currently, I'm use the following example code in my Macros to protect
and unprotect the document:

If ActiveDocument.ProtectionType <> wdNoProtection Then
bProtected = True
ActiveDocument.Unprotect Password:="password1"
End If

I would like to be able to capture any password that is entered and define
it as a string, or something, then use something like:

If ActiveDocument.ProtectionType ...
ActiveDocument.Unprotect Password:= Defined Password
End If

Kind regards
Dylan
 
J

Jean-Guy Marcil

DDawson said:
Is there a way to capture the manually entered password so that I can assign
it to macros?

As you may already know, the document needs to be unprotected for the macros
to run. Currently, I'm use the following example code in my Macros to protect
and unprotect the document:

If ActiveDocument.ProtectionType <> wdNoProtection Then
bProtected = True
ActiveDocument.Unprotect Password:="password1"
End If

I would like to be able to capture any password that is entered and define
it as a string, or something, then use something like:

If ActiveDocument.ProtectionType ...
ActiveDocument.Unprotect Password:= Defined Password
End If

If you want to capture a user-defined password on the fly, you have to
create your own password-setting utility and force users to use your utility
to protect the document.

Your utility can be in two parts:
1) When protecting the document, if no password is stored in memory, force
the user to create a password and then store it.
2) If a passowrd exists, offer a two-button option: "Protect" (Automatically
using the previously set password.) and "Change Password" (To change the
password before protecting the document.).

It is not too difficult. All you need are two little userforms.
You can store the password as a Document Variable.
 

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

Top