0
votes

I would like to use vba to protect my word document.

Indeed, it is possible but I've searched on how to unprotect the document through this link :
http://www.aurelp.com/2015/04/01/how-to-unlock-a-microsoft-word-document-step-by-stepsolved/

Is there any other way on how to successfully protect the document from unauthorized user?

1

1 Answers

3
votes

Using VBA, I believe you'd be looking for the protect method:

Application.ActiveDocument.Protect wdAllowOnlyRevisions, password:="password"

With protect, you can specify the type of protection, the password, and various components of the protection (style lock, resetting of form fields, etc.). More on protect can be found here.

Likewise, VBA has a similar method for unprotecting a Word document, if you know the password. This is the aptly named unprotect method.

Application.ActiveDocument.Unprotect "password"

More on unprotect can be found here.