简体   繁体   中英

Error 1004 error defined by application or object

I am trying to change the font color of a cell using VBA. The reason why I can't change it directly in excel is because the worksheet is protected and I do not have the password. The cell I want to change is not blocked ( I can type in it).

In the Worksheet code I have tried using changing the color but the error 1004 always pops up when it is going to activate the code.

Private Sub Worksheet_Change(ByVal Target as Range)
  Range("B25").Font.Color = vbWhite
End Sub

I want the code to work so the cell Font is always white no matter what is typed in it

The reason why I can't change it directly in excel is because the worksheet is protected and I do not have the password.

Then VBA code can't change it either.

You can try hash-colliding the password and, if you're lucky, you'll be able to unprotect the sheet (note: that link is hash-colliding workbook protection - you'll want to tweak it a bit to crack worksheet protection) with a password that produces the same hash as the actual password.

If you're unlucky, well... you're out of luck.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM