尽管Application.ScreenUpdating = False,按钮仍会闪烁?

时间:2015-01-28 15:40:14

标签: excel vba excel-vba

我有一个课程,我在一些潜艇的开头叫:

Private bSattOmdomenProtected As Boolean
Private bSkapaOmdomeslistorProtected As Boolean


Private Sub Class_Initialize()
    Application.ScreenUpdating = False
    Application.EnableEvents = False
    Application.Cursor = xlWait


    'Protection
    bSattOmdomenProtected = wSattOmdomen.ProtectContents
    bSkapaOmdomeslistorProtected = wSkapaOmdomeslistor.ProtectContents
    wSattOmdomen.Unprotect
    wSkapaOmdomeslistor.Unprotect
    'End protection

End Sub

Private Sub Class_Terminate()


    'Protection
    If bSattOmdomenProtected Then
        wSattOmdomen.Protect AllowSorting:=True, AllowFiltering:=True 'AllowFormattingCells:=True , UserInterfaceOnly:=True
    End If
    If bSkapaOmdomeslistorProtected Then
        wSkapaOmdomeslistor.Protect AllowSorting:=True, AllowFiltering:=True 'AllowFormattingCells:=True,, UserInterfaceOnly:=True
    End If
    'End protection

    Application.Cursor = xlDefault
    Application.EnableEvents = True
    Application.ScreenUpdating = True
End Sub

我如何调用该类的示例:

Sub Example()
    Dim general As New cGeneralLines
    Set general = New cGeneralLines

    'Code
End Sub

我发现这适用于设置应用程序状态。但是由于我在类中添加了标记为Protection的代码,所以即使我设置了Application.ScreenUpdating = False,我工作表中的所有按钮都会闪烁。

导致闪烁的特定行似乎是当我尝试更改另一张表的保护设置而非活动表时。

这是为什么?如何获得表单保护代码的功能,但避免出现闪烁的按钮?

0 个答案:

没有答案