另一个VBA Bug? [英] Another VBA Bug?

查看:93
本文介绍了另一个VBA Bug?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hi Folks,

我正在针对受保护的工作表运行以下代码(使用UserInterface:= True)并且失败:

I am running the following code against a protected sheet (with UserInterface:=True) and it fails:

使用ActiveCell.Offset(2,-3)。验证

        .Delete

        .Add Type:= xlValidateList,_

            AlertStyle:= xlValidAlertStop,_

            运营商:= xlBetween,_

             Formula1:=" = bu"

    ;      .IgnoreBlank = True

        .InCellDropdown = True

        .ShowError = True

   结束

With ActiveCell.Offset(2, -3).Validation
        .Delete
        .Add Type:=xlValidateList, _
            AlertStyle:=xlValidAlertStop, _
            Operator:=xlBetween, _
            Formula1:="=bu"
        .IgnoreBlank = True
        .InCellDropdown = True
        .ShowError = True
    End With

代码在添加行上失败。 此行在未受保护的工作表上正常运行。 我可以解除保护和重新保护,但我错过了其他的东西。

The code fails on the Add line.  This line runs fine on an unprotected sheet.  I can Unprotect and Reprotect but am I missing something else.

TIA,

Shane

如果此答案解决了您的问题,请选中标记为已回答。如果此答案有帮助,请单击"投票为有用"按钮。干杯,Shane Devenshire

If this answer solves your problem, please check Mark as Answered. If this answer helps, please click the Vote as Helpful button. Cheers, Shane Devenshire

推荐答案

Bing是你的朋友......我发现了这个花絮:

Bing is your friend...I found this tidbit:

If you apply the Protect method with the UserInterfaceOnly argument set to True

应用于工作表,然后保存工作簿,

to a worksheet and then save the workbook,

整个工作表(不是只需界面)将在您重新打开工作簿时得到完全保护。

the entire worksheet (not just the interface) will be fully protected when you reopen the workbook.

要取消保护工作表,但在打开工作簿后重新启用用户界面保护,

To unprotect the worksheet but re-enable user interface protection after the workbook is opened,

必须再次应用Protect方法并将UserInterfaceOnly设置为True。

you must again apply the Protect method with UserInterfaceOnly set to True.


只需将Protect方法调用放入Workbook Open事件处理程序中。

Just put the Protect method call in the Workbook Open event handler.


这篇关于另一个VBA Bug?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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