工作表保护:UserInterFaceOnly不见了

编程入门 行业动态 更新时间:2024-10-24 02:01:04
本文介绍了工作表保护: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不见了

本文发布于:2023-11-16 18:50:24,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1606891.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:不见了   工作   UserInterFaceOnly

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!