In VBA Excel if I protect sheets with UserInterFaceOnly:=True
option after I close and open the file again the UserInterFaceOnly
mode is not activ
I'm not sure what the cause of that issue is, but you can circumvent it by adding protection code to the Workbook_Open()
event, resetting every sheet protection to have UserInterfaceOnly:=True
in each
You can't do it without reapplying UserInterfaceOnly:=True
after reopening the workbook. Taken from Excel's Vb protect method reference:
If you apply this method with the UserInterfaceOnly argument set to true and then save the workbook, the entire worksheet (not just the interface) will be fully protected when you reopen the workbook. To re-enable the user interface protection after the workbook is opened, you must again apply this method with UserInterfaceOnly set to true
Now, if your concern is that this takes too long (15 seconds, as you say), take a look at this Code Review answer. I have done this in several workbooks of varying level of complexity, and the time for reapplying protection is negligible in all versions I've tried, including 2010.