
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback. If aDoc.ProtectionType wdNoProtection ThenĪDoc.Protect Type:=wdAllowOnlyRevisions, Password:=strPassword Types edit There are two groups of passwords that can be set to a document: 1 A password to encrypt a document restricts opening and viewing it. Text is inserted, and the document is protected for revisions. Microsoft Office password protection is a security feature to protect Microsoft Office documents (Word, Excel, PowerPoint) with a user-provided password. This example removes protection from the active document. If ActiveDocument.ProtectionType wdNoProtection ThenĪctiveDocument.Unprotect Password:=strPassword This example removes protection from the active document, using the value of the strPassword variable as the password. If the document isn't protected, this method generates an error. For recommended best practices on how to do this, see Security notes for Office solution developers. If a password is required in a procedure, request the password from the user, store it in a variable, and then use the variable in your code.

Passwords for those are also 'password123.

You can also download documents made with Word 2010 and Word 2016 (that shows up as 2013) to use for more examples. Avoid using hard-coded passwords in your applications. The password is 'password123' as youll find out.
