vba 打开工作簿时关闭 Excel 后台错误检查

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4754108/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 12:33:08  来源:igfitidea点击:

Turn off Excel Background Error Checking on opening the workbook

excelvbaexcel-vba

提问by Craig T

I have an excel workbook was has lots of the green "error checking" triangles.

我有一个 excel 工作簿,上面有很多绿色的“错误检查”三角形。

Is there any way using Excel VBA that I can this off when I open the workbook.

当我打开工作簿时,有什么方法可以使用 Excel VBA 来关闭它。

回答by Marc Thibault

I think this is what you're looking for:

我认为这就是你要找的:

    Application.ErrorCheckingOptions.BackgroundChecking = False

回答by Craig T

I found the answer that I was after:

我找到了我想要的答案:

Sub Auto_Open()
    Application.ErrorCheckingOptions.BackgroundChecking = False 
End Sub

回答by Krisha

I usually split my workbook tabs into Data, Calculations and Presentation. As such, I don't like the green error checking triangles for tables within my 'Presentation' tabs. One approach is to protect the sheet...the green checks go away! (and only for that tab)

我通常将我的工作簿标签分成数据、计算和演示。因此,我不喜欢“演示”选项卡中表格的绿色错误检查三角形。一种方法是保护床单……绿色支票消失了!(并且仅适用于该选项卡)

If you still want the protected tab to be accessible then just unlock all the cells and select the appropriate protection options prior to protecting it.

如果您仍然希望可以访问受保护的选项卡,则只需解锁所有单元格并在保护它之前选择适当的保护选项。

I'd stay away from using macros as this may affect the users settings across various workbooks and tabs.

我不会使用宏,因为这可能会影响各种工作簿和选项卡的用户设置。

回答by Mahdi Jazini

Simply use this:

只需使用这个:

With Application.ErrorCheckingOptions
    .BackgroundChecking = False
    .EvaluateToError = False
    .TextDate = False
    .NumberAsText = False
    .InconsistentFormula = False
    .OmittedCells = False
    .UnlockedFormulaCells = False
    .ListDataValidation = False
End With

If you use the above code, it turns off this future forever and for all excel documents.

如果您使用上面的代码,它将永远关闭所有 excel 文档的未来。

But If you would like to do it just for your excel document (not for all) do this:

但是,如果您只想为您的 excel 文档(并非所有人)执行此操作,请执行以下操作:

    '''''''''''''''' IN A MODULE '''''''''''''''''''
    Public AE_BackgroundChecking As Boolean
    Public AE_EvaluateToError As Boolean
    Public AE_TextDate As Boolean
    Public AE_NumberAsText As Boolean
    Public AE_InconsistentFormula As Boolean
    Public AE_OmittedCells As Boolean
    Public AE_UnlockedFormulaCells As Boolean
    Public AE_ListDataValidation As Boolean
    Public AE_EmptyCellReferences As Boolean
    ''''''''''''''''''''''''''''''''''''''''''''''''

    ''''''''''''''''' IN WORKBOOK OPEN EVENT '''''''''''''

    AE_BackgroundChecking = Application.ErrorCheckingOptions.BackgroundChecking
    AE_EvaluateToError = Application.ErrorCheckingOptions.EvaluateToError
    AE_TextDate = Application.ErrorCheckingOptions.TextDate
    AE_NumberAsText = Application.ErrorCheckingOptions.NumberAsText
    AE_InconsistentFormula = Application.ErrorCheckingOptions.InconsistentFormula
    AE_OmittedCells = Application.ErrorCheckingOptions.OmittedCells
    AE_UnlockedFormulaCells = Application.ErrorCheckingOptions.UnlockedFormulaCells
    AE_ListDataValidation = Application.ErrorCheckingOptions.ListDataValidation
    AE_EmptyCellReferences = Application.ErrorCheckingOptions.EmptyCellReferences

    With Application.ErrorCheckingOptions
        .BackgroundChecking = False
        .EvaluateToError = False
        .TextDate = False
        .NumberAsText = False
        .InconsistentFormula = False
        .OmittedCells = False
        .UnlockedFormulaCells = False
        .ListDataValidation = False
        .EmptyCellReferences = False
    End With
    ''''''''''''''''''''''''''''''''''''''''''



''''''''''''''''' IN WORKBOOK CLOSE EVENT '''''''''''''
Application.ErrorCheckingOptions.BackgroundChecking = AE_BackgroundChecking
Application.ErrorCheckingOptions.EvaluateToError = AE_EvaluateToError
Application.ErrorCheckingOptions.TextDate = AE_TextDate
Application.ErrorCheckingOptions.NumberAsText = AE_NumberAsText
Application.ErrorCheckingOptions.InconsistentFormula = AE_InconsistentFormula
Application.ErrorCheckingOptions.OmittedCells = AE_OmittedCells
Application.ErrorCheckingOptions.UnlockedFormulaCells = AE_UnlockedFormulaCells
Application.ErrorCheckingOptions.ListDataValidation = AE_ListDataValidation
Application.ErrorCheckingOptions.EmptyCellReferences = AE_EmptyCellReferences
'''''''''''''''''''''''''''''''''''''''''''''''''''''''