Workbook.SetPasswordEncryptionOptions (Excel)

Sets the options for encrypting workbooks by using passwords.

The PasswordEncryptionProvider, PasswordEncryptionAlgorithm, and PasswordEncryptionKeyLength arguments are not independent of each other. A selected encryption provider limits the set of algorithms and key length that can be chosen. For the PasswordEncryptionKeyLength argument, there is no inherent limit on the range of the key length. The range is determined by the Cryptographic Service Provider, which also determines the cryptographic algorithm.

SetPasswordEncryptionOptions (PasswordEncryptionProvider, PasswordEncryptionAlgorithm, PasswordEncryptionKeyLength, PasswordEncryptionFileProperties)


ActiveWorkbook.SetPasswordEncryptionOptions _ 
 PasswordEncryptionProvider:="Microsoft RSA SChannel Cryptographic Provider", _ 
 PasswordEncryptionAlgorithm:="RC4", PasswordEncryptionKeyLength:=56,  PasswordEncryptionFileProperties:=True

Arguments

Optional arguments

The following arguments are optional

PasswordEncryptionProvider - A case-sensitive string of the encryption provider

PasswordEncryptionAlgorithm - A case-sensitive string of the algorithmic short name (that is, "RC4")

PasswordEncryptionKeyLength - The encryption key length which is a multiple of 8 (40 or greater)

PasswordEncryptionFileProperties - True (default) to encrypt file properties