我有一个Excel工作簿,里面有很多绿色的“错误检查”三角形。
是否有办法在打开工作簿时使用Excel VBA将其关闭?
我认为这就是你要找的:
Application.ErrorCheckingOptions.BackgroundChecking = False
ThisWorkbook
宏页面内的 Private Sub Workbook_Open()
中。 - RachchaSub Auto_Open()
Application.ErrorCheckingOptions.BackgroundChecking = False
End Sub
只需使用这个:
With Application.ErrorCheckingOptions
.BackgroundChecking = False
.EvaluateToError = False
.TextDate = False
.NumberAsText = False
.InconsistentFormula = False
.OmittedCells = False
.UnlockedFormulaCells = False
.ListDataValidation = False
End With
'''''''''''''''' 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
'''''''''''''''''''''''''''''''''''''''''''''''''''''''
Application.ErrorCheckingOptions.BackgroundChecking = True
,然后进行可能出现错误检查的操作,最后使用Application.ErrorCheckingOptions.BackgroundChecking = False
重新激活它即可。 - micskyOn Error Resume Next
'MyCode
If Err.Number > 0 Then
'Code if error
Else
End If
On Error GoTo 0