目录

# 错误报告

Defines the error message that is displayed when invalid data is entered in a cell.

您还可以启动一个显示错误信息的宏。此页面的结尾处提供了一个示例宏。

要访问此命令...

#### From the menu bar:

选择「数据 - 有效性 - 错误报告」选项卡。

#### From the tabbed interface:

On the Data menu of the Data tab, choose Validity - Error Alert tab.

## 在输入无效值时显示错误报告。

当单元格中输入了无效的数据时，将显示「内容」区域中输入的错误消息。 如果已启用此选项，将显示该消息以避免输入无效数据。

对于这两种情况，如果选择「停止」，将删除无效的条目且单元格被重新输入以前的数值。如果您点击「取消」按钮关闭了「警告」和「信息」对话框，也将执行相同的操作。如果您按下「确定」按钮关闭对话框，则不会删除无效的条目。

## 内容

### 操作

Select the action that you want to occur when invalid data is entered in a cell.

- The Stop action rejects the invalid entry and displays a dialog that you have to close by clicking OK.

- The Warning and Information actions display a dialog that can be closed by clicking OK or Cancel. The invalid entry is only rejected when you click Cancel.

- The Reject Silently action keeps the current cell value and does not display a dialog.

### 浏览

打开宏对话框，可以从中选择一个宏，以便当单元格中输入无效数据时执行该宏。显示错误报告后将执行宏。

### 标题

输入宏标题，或输入单元格中出现无效数据时要显示的错误消息。

### 错误报告

输入单元格中出现无效数据时要显示的消息。

### 示例宏:

Below is a sample function that can be called when an error occurs. Note that the macro takes in two parameters that are passed on by LibreOffice when the function is called:

- CellValue: The value entered by the user, as a String.

- CellAddress: The address of the cell where the value was entered, as a String prefixed with the sheet name (e.g: "Sheet1.A1").

The function must return a Boolean value. If it returns True, the entered value is kept. If the function returns False, the entered value is erased and the previous value is restored.

        Function ExampleValidity(CellValue as String, CellAddress as String) as Boolean
            Dim msg as String
            Dim iAnswer as Integer
            Dim MB_FLAGS as Integer
            msg = "Invalid value: " & "'" & CellValue & "'"
            msg = msg & " in cell: " & "'" & CellAddress & "'"
            msg = msg & Chr(10) & "Accept anyway?"
            MB_FLAGS = MB_YESNO + MB_ICONEXCLAMATION + MB_DEFBUTTON2
            iAnswer = MsgBox (msg , MB_FLAGS, "Error message")
            ExampleValidity = (iAnswer = IDYES)
        End Function

相关主题

Validity

请支持我们!