工作表保护:UserInterFaceOnly不见了 [英] Sheet protection: UserInterFaceOnly gone

查看:168
本文介绍了工作表保护:UserInterFaceOnly不见了的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在VBA Excel中,如果我在关闭并再次打开文件后使用UserInterFaceOnly:=True选项保护工作表,则UserInterFaceOnly模式不处于活动状态,仅密码保护.

In VBA Excel if I protect sheets with UserInterFaceOnly:=True option after I close and open the file again the UserInterFaceOnly mode is not active, only Password protection.

代码:ActiveSheet.Protect Password:="myPassword", UserInterfaceOnly:=True

为什么?

推荐答案

重新打开工作簿后,如果不重新应用UserInterfaceOnly:=True,您将无法做到这一点.取自Excel的Vb

You can't do it without reapplying UserInterfaceOnly:=True after reopening the workbook. Taken from Excel's Vb protect method reference:

如果在UserInterfaceOnly参数设置为true的情况下应用此方法,然后保存工作簿,则当您重新打开工作簿时,整个工作表(而不仅仅是接口)将受到完全保护.要在打开工作簿后重新启用用户界面保护,必须在UserInterfaceOnly设置为true的情况下再次应用此方法

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

现在,如果您担心此过程花费的时间太长(如您所说的15秒),请查看代码查看答案.我已经在几本复杂程度各异的工作簿中做到了这一点,并且在我尝试过的所有版本(包括2010年)中,重新应用保护的时间都可以忽略不计.

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.

这篇关于工作表保护:UserInterFaceOnly不见了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆