Share via

Security Excel

Orkit 45 Reputation points
2025-01-15T22:08:56.6533333+00:00

After browsing several forums, I find that the only real security for an Excel file is encryption with a password. Unfortunately, a person who knows the password can change it after having access to the file. Is it possible with VBA to put a password in the case of encryption so that even if one user changes the password, the correct password overrides the other?

I saw this:

Sub SetPasswordOptions()

ActiveWorkbook.SetPasswordEncryptionOptions _

PasswordEncryptionProvider:="Microsoft RSA SChannel Cryptographic Provider", _

PasswordEncryptionAlgorithm:="RC4", _

PasswordEncryptionKeyLength:=56, _

PasswordEncryptionFileProperties:=True

End Sub

But I don’t know where to put the password I want to impose.

Thank you in advance.

The security settings of Excel files must evolve, in particular passwords on the workbook and on sheets that are visibly easy to hack just with sheets for example!

Microsoft 365 and Office | Development | Other
Microsoft 365 and Office | Excel | For business | Windows
0 comments No comments

1 answer

Sort by: Most helpful
  1. Jiajing Hua 18,110 Reputation points Moderator
    2025-01-16T07:53:05.8966667+00:00

    Hi @Orkit

    There is no way in Excel to enforce a fixed password that cannot be changed by other users.

    You can use VBA to add another layer of password protection when users open a file, but VBA itself cannot prevent someone from changing the password after they have access to the file.

    Maybe you need to check whether there is a third-party encryption software that can meet your needs.

    Thanks for your understanding.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


    Was this answer helpful?

    1 person found this answer helpful.

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.