主题
Error (对象)
代表区域的电子表格错误。
说明
使用 Errors 对象的 Item 属性可返回 Error 对象。
返回 Error 对象后,可结合使用 Value 和 Errors属性检查某个特定错误检查选项是否已启用。
注释 |
---|
不要将 Error 对象与 Visual Basic 的错误处理功能混淆。 |
python
#下例中,在引用空单元格的单元格 A1 中创建一个公式,然后使用 Item(index)(其中 index 用于标识错误类型)显示描述错误情况的消息
def test():
rngFormula = Application.Range("A1")
# Place a formula referencing empty cells.
Range("A1").Formula = "=A2+A3"
Application.ErrorCheckingOptions.EmptyCellReferences = True
# Perform check to see if EmptyCellReferences check is on.
if rngFormula.Errors.Item(xlEmptyCellReferences).Value == True:
print("The empty cell references error checking feature is enabled.")
else:
print("The empty cell references error checking feature is not on.")