-
You could protect the sheet while opening the workbook using the UserInterfaceOnly argument. And the VBA code will work as it is, and still not allow users to delete the picture or text. Of course the cells involved, and the pictures will have to have locked property.
-
e
Excel Fox
Would you have that code to suit the worksheet with the picture and text
Thanks
-
Just typing this on the fly... watch out for any typ0s
Code:
Sub Auto_Open()
Dim wks as worksheet
for each wks in thisworkbook.worksheets
wks.Unprotect PassWord:=""' If there's a password, use it within the double quote
wks.Protect UserInterfaceOnly:=True, Password=""' If there's a password, use it within the double quote
next wks
End Sub
-
If you were just wanting to protect that particular sheet, then use
Code:
Sub Auto_Open()
With Worksheets("Particular Sheet Name")
.Unprotect PassWord:=""' If there's a password, use it within the double quote
.Protect UserInterfaceOnly:=True, Password:=""' If there's a password, use it within the double quote
End With
End Sub
EDIT: Added a semi-colon to the argument
-
use the following code but get a error-expected named parameter
Code:
Sub Auto_Open()
With Worksheets("sheet1")
.Unprotect Password:="hello" ' If there's a password, use it within the double quote
.Protect UserInterfaceOnly:=True, Password="hello"' If there's a password, use it within the double quote
End With
End Sub
-
I fixed a typo as you suggested so the code does not give error but it still allows me to delete the cell contents and it does not ask for passwords
Thanks
-
I've made a small correction. Check my previous post.
-
The code has to be pasted in a code module, and not in the sheet module or workbook module. Also ensure that the cell you're using is locked.