VBA error 1004-password incorrect caps lock on

soleturnes

New Member
Joined
Sep 26, 2022
Messages
7
Office Version
  1. 365
Platform
  1. Windows
Hi! I have an excel file with some macros, which i've been using for a while, that protect and unprotect the workbook, with the password written in the code, but for some reason it isn´t recognizing now the password.
The password hasn´t been changed.
Could someone please help me?

I'll post my code below, but it works fine with other files.
1664214450558.png


Code to unprotect:
ActiveWorkbook.Protect Password:="xx", Structure:=False

I've already tried without success:
ThisWorkbook.Protect Password:="xx", Structure:=False
Workbooks("NAME").Protect Password:="xx", Structure:=False
ActiveWorkbook.UnProtect Password:="xx"
ActiveWorkbook.UnProtect (["xx"])
Opening it in Safe Mode

When trying to unlock the workbook in the review tab I get the same error

Thanks!
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
I hate to be the bearer of bad news, but if it's the same code that has been working for a long time, and if you cannot unlock it manually then it suggests two possibilities:

1. Somehow (this usually means 'someone') the password was changed.
2. The file is corrupt and the valid password is not recognized because stored password hash is corrupt.
 
Upvote 0
Welcome to the Board!

I have to ask/rule out the obvious here.

Based on the title of your thread:

VBA error 1004-password incorrect caps lock on

Are you sure that the issue isn't that the Caps Lock button is on while you are trying to enter the password?
If you toggle the Caps Lock button (press it once), and then re-enter the password, does it work then?
 
Upvote 0
Welcome to the Board!

I have to ask/rule out the obvious here.

Based on the title of your thread:

Are you sure that the issue isn't that the Caps Lock button is on while you are trying to enter the password?
If you toggle the Caps Lock button (press it once), and then re-enter the password, does it work then?
Yes, i´ve tried the caps lock button and copy/paste it , and also it's written in the code and after debugging it, gives the same error
 
Upvote 0
Then I concur with what rlv01 has said.
Most likely either it has a different password, or the workbook has become corrupted.
 
Upvote 0
I hate to be the bearer of bad news, but if it's the same code that has been working for a long time, and if you cannot unlock it manually then it suggests two possibilities:

1. Somehow (this usually means 'someone') the password was changed.
2. The file is corrupt and the valid password is not recognized because stored password hash is corrupt.
I don't think someone could change the password because the VBA is locked with another password that only I know. Could someone changed it in the review tab?
How could it became corrupt? :( is there a way to fix it?

Thanks!!
 
Upvote 0
Usually people keep a blank master version and frequent backups of their data/workbooks, that way if the worst happens then you can extract the data and revert everything back to how it was. If you don't do that, then now might be a good time to start.
 
Upvote 0
Usually people keep a blank master version and frequent backups of their data/workbooks, that way if the worst happens then you can extract the data and revert everything back to how it was. If you don't do that, then now might be a good time to start.
I do, but wanted to know if it was fixable as I can´t find an explanation for this error
 
Upvote 0
I do, but wanted to know if it was fixable as I can´t find an explanation for this error

Another thing to consider is a log sheet of some description. During a before close event you can test if the password in use matches what it should be, if not log the error with user details, better still have it send you a message via CDO mail.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top