錯誤警示

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

您也可以透過錯誤訊息來啟動巨集。此頁的結尾提供了一個巨集示例。

若要使用此指令...

Choose Data - Validity - Error Alert tab.


顯示輸入無效值時的錯誤報告

當儲存格中輸入了無效的資料時,會顯示您在 [內容] 區域內進行輸入的錯誤訊息。若已啟用,則會顯示此訊息以防止無效的輸入。

對於這兩種情況,如果選取「暫停」,無效的輸入會被刪除且先前的數值被重新輸入儲存格中。如果您按一下[取消]按鈕關閉「警告」和「資訊」對話方塊,也會出現相同的情形。如果您按一下[確定]按鈕關閉這些對話方塊,則無效的輸入不會被刪除。

內容

動作

選取當儲存格中輸入了無效的資料時要發生的動作。 「停止」動作會拒絕無效的項目並顯示讓您按一下 [確定] 以關閉對話方塊。「警告」和「資訊」動作顯示一個對話方塊,按一下 [確定][取消] 可關閉此對話方塊,僅當您按一下 [取消] 時,才能拒絕無效的輸入。

瀏覽

開啟[巨集] 對話方塊,在此處您可以選取當儲存格中輸入了無效資料時執行的巨集。此巨集在顯示錯誤訊息後執行。

標題

輸入當儲存格中輸入了無效的資料時要顯示的巨集之標題或錯誤訊息。

錯誤報告

輸入當儲存格中輸入了無效的資料時要顯示的訊息。

Sample macro:

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:

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
  

Please support us!