Hello guys,
before I get misunderstood I'll make it clear. This is not a thread about hacking/cracking Excel/VBA passwords, the situation follows:
I have a project in Excel and it contains some sensitive data, it's not top secret but I'd like to avoid anyone beeing able to open the file and read the content. For this purpose I set 2 passwords, one for "Open" and another for "Write", both are Workbook's property (ActiveWorkbook.Password) and (ActiveWorkbook.WritePassword). However, this file won't be used just by me and I'd like to write a VBA code so that the User can change the password as he wants. The code for setting the password is really simple and I already have it:
But there is something bothering me: Excel doesn't ask you the current password, he just changes it without questioning and that's a big problem imo. I tried to write a code to get the current password, so I can verify if they match and only then, change the password. I tried:
but if I try to compare the current open password and the content of verOPW, for exemple, I get always "FALSE" and if I try to read the value of verOPW, all I get is *******.
So I'd like to kindly ask if someone knows how could I make this verification with the current password before I set one anew.
Thanks in advance and best regards!
before I get misunderstood I'll make it clear. This is not a thread about hacking/cracking Excel/VBA passwords, the situation follows:
I have a project in Excel and it contains some sensitive data, it's not top secret but I'd like to avoid anyone beeing able to open the file and read the content. For this purpose I set 2 passwords, one for "Open" and another for "Write", both are Workbook's property (ActiveWorkbook.Password) and (ActiveWorkbook.WritePassword). However, this file won't be used just by me and I'd like to write a VBA code so that the User can change the password as he wants. The code for setting the password is really simple and I already have it:
Code:
Dim strOPW as string, strWPW as string
'inputbox or form
ActiveWorkbook.Password = OPW
ActiveWorkbook.WritePassword = WPW
But there is something bothering me: Excel doesn't ask you the current password, he just changes it without questioning and that's a big problem imo. I tried to write a code to get the current password, so I can verify if they match and only then, change the password. I tried:
Code:
verOPW = ActiveWorkbook.Password
verWPW = ActiveWorkbook.WritePassword
but if I try to compare the current open password and the content of verOPW, for exemple, I get always "FALSE" and if I try to read the value of verOPW, all I get is *******.
So I'd like to kindly ask if someone knows how could I make this verification with the current password before I set one anew.
Thanks in advance and best regards!