View Single Post
 
Old 01-25-2021, 05:47 AM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,144
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

In order to run when the document is opened, the macro needs to be renamed AutoOpen and the document should be saved as macro enabled. However you cannot force the user to run the macro.

Code:
Sub AutoOpen()
Const strPassword As String = "password"
    With ActiveDocument
        If Not .ProtectionType = wdNoProtection Then
            .Unprotect Password:=strPassword
        End If
        .Revisions.AcceptAll
        .Protect Password:=strPassword, _
                 NoReset:=False, _
                 Type:=wdAllowOnlyReading, _
                 UseIRM:=False, _
                 EnforceStyleLock:=False
    End With
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote