如果当前使用的密码加密算法是标准加密,以前版本所使用的加密算法“OfficeXor”,则本示例将重新设置密码加密选项。

With ActiveDocument
    If .PasswordEncryptionAlgorithm = "OfficeXor" Then
        .SetPasswordEncryptionOptions _
        PasswordEncryptionProvider:="Microsoft RSA SChannel Cryptographic Provider", _
        PasswordEncryptionAlgorithm:="RC4", _
        PasswordEncryptionKeyLength:=56, _
        PasswordEncryptionFileProperties:=True
    End If
End With