本文介绍了工作表保护: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:

现在,如果您担心此过程花费的时间太长(如您所说的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不见了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-10 00:49