What are possible reason when protection with "userinterfaceonly:=True" won't work?

pedie

Well-known Member
Joined
Apr 28, 2010
Messages
3,875
What are possible reason when protection with "userinterfaceonly:=True" won't work?
Below is my code. It works now but @ work it wont work. It keeps repeating that sheet/chart is protected....unlock it...

I dont want the code to unlock and then protect it back everytime i run macro....

Please suggest!
Code:
[/FONT]
[FONT=Courier New]Sub try()
 Sheet2.Protect Password:="123", userinterfaceonly:=True
End Sub[/FONT]
[FONT=Courier New]

PS. The ribbon is completly hidden with excel4macro


Thanks.

Pedie
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
This is one reason I don't like using userinterfaceonly...

The userinterfaceonly setting is NOT saved when you save/close/reopen the book.
You have to use the
Private Sub Workbook_Open()
event code to set it every time you open the book.

Hope that helps.
 
Upvote 0
Do i have to unprotect it when the workbook closes and then let the workbook open event protect it again?
is that what you guys mean?:)

Thanks again for suggestions.
 
Upvote 0
No (provided you have the correct password).
Just protect it with the userinterfaceonly option using the workbook open event.
 
Upvote 0
Works perfect here at home. Will try back tomorrow if it still persist.
Thanks for your time Peter, and jonmo1.:)
 
Upvote 0

Forum statistics

Threads
1,224,581
Messages
6,179,668
Members
452,936
Latest member
anamikabhargaw

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