Sheet protection: UserInterFaceOnly gone

后端 未结 2 1617
臣服心动
臣服心动 2020-11-30 14:28

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

相关标签:
2条回答
  • 2020-11-30 14:31

    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

    0 讨论(0)
  • 2020-11-30 14:37

    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.

    0 讨论(0)
提交回复
热议问题