Contido

# Alerta de erro

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

You can also start a macro with an error message. A sample macro is provided at the end of this page.

Para acceder a esta orde...

#### From the menu bar:

Escolla a lapela Datos - Validación - Alerta de erro.

#### From the tabbed interface:

No menú datos da lapela datos escolla a lapela Validación - Alerta de erro.

## Mostrar unha mensaxe de erro cando se insiren valores non válidos.

Displays the error message that you enter in the Contents area when invalid data is entered in a cell. If enabled, the message is displayed to prevent an invalid entry.

In both cases, if you select "Stop", the invalid entry is deleted and the previous value is reentered in the cell. The same applies if you close the "Warning" and "Information" dialogs by clicking the Cancel button. If you close the dialogs with the OK button, the invalid entry is not deleted.

## Contido

### Acción

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.

### Explorar

Opens the Macro dialog where you can select the macro that is executed when invalid data is entered in a cell. The macro is executed after the error message is displayed.

### Título

Enter the title of the macro or the error message that you want to display when invalid data is entered in a cell.

### Mensaxe de erro

Enter the message that you want to display when invalid data is entered in a cell.

### Sample macro:

Abaixo hai unha función de exemplo que pode ser chamada ao producirse un erro. Teña en conta que a macro toma dous parámetros que son pasados polo LibreOffice ao invocar a función:

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

- Enderezo da cela: O enderezo da cela no que se introduciu o valor, como cadea prefixada co nome da folla (por exemplo: «Folla1.A1»).

A función debe devolver un valor lóxico. Se devolve Verdadeiro, o valor introducido mantense. Se a función devolve Falso, o valor introducido límpase e restáurase o valor anterior.

        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

Temas relacionados

Validity

Precisamos da súa axuda!