Condividi tramite


NamedRange.Errors Property

Definition

Gets an Errors object that enables you to access error checking options.

public:
 property Microsoft::Office::Interop::Excel::Errors ^ Errors { Microsoft::Office::Interop::Excel::Errors ^ get(); };
public Microsoft.Office.Interop.Excel.Errors Errors { get; }
member this.Errors : Microsoft.Office.Interop.Excel.Errors
Public ReadOnly Property Errors As Errors

Property Value

An Errors object that enables you to access error checking options.

Examples

The following code example creates a NamedRange and inserts a number written as text into the range, and then uses the Errors property to determine whether the number is written as text.

This example is for a document-level customization.

Microsoft.Office.Tools.Excel.NamedRange errorsRange;
private void CheckForErrors()
{
    errorsRange = this.Controls.AddNamedRange(
        this.Range["C3"], "errorsRange");
    this.errorsRange.Formula = "'12";

    if (this.errorsRange.Errors[
        Excel.XlErrorChecks.xlNumberAsText].Value)
    {
        MessageBox.Show("The number is written as text.");
    }
    else
    {
        MessageBox.Show("The number is not written as text.");
    }
}
Private errorsRange As Microsoft.Office.Tools.Excel.NamedRange

Private Sub CheckForErrors()
    errorsRange = Me.Controls.AddNamedRange(Me.Range("C3"), _
        "errorsRange")
    Me.errorsRange.Formula = "'12"

    If Me.errorsRange.Errors( _
        Excel.XlErrorChecks.xlNumberAsText).Value Then
        MessageBox.Show("The number is written as text.")
    Else
        MessageBox.Show("The number is not written as text.")
    End If
End Sub

Remarks

Reference the Errors object to view a list of index values associated with error checking options.

Applies to