Partager via


XmlMappedRange.AutoComplete Method

Gets an AutoComplete match from the list.

Namespace:  Microsoft.Office.Tools.Excel
Assembly:  Microsoft.Office.Tools.Excel (in Microsoft.Office.Tools.Excel.dll)

Syntax

'Declaration
Function AutoComplete ( _
    String As String _
) As String
string AutoComplete(
    string String
)

Parameters

Return Value

Type: System.String
An AutoComplete match from the list.

Remarks

If there is no AutoComplete match or if more than one entry in the list matches the string to complete, this method returns an empty string.

This method works even if the AutoComplete feature is disabled.

Examples

The following code example enters the string "Smith" into cell B1, and then uses the AutoComplete method to find an AutoComplete match for the string "Smi". This code example assumes that the current worksheet contains an XmlMappedRange named CustomerLastNameCell. The AutoComplete match will be found if CustomerLastNameCell is in cell B2.

Private Sub DisplayAutoCompleteResult()
    Me.Range("B1").Value2 = "Smith" 
    Dim autoString As String = Me.CustomerLastNameCell.AutoComplete("Smi")

    If String.IsNullOrEmpty(autoString) Then
        MsgBox("No AutoComplete results were found.")
    Else 
        Me.CustomerLastNameCell.Value2 = autoString
    End If 
End Sub
private void DisplayAutoCompleteResult()
{
    this.Range["B1", missing].Value2 = "Smith";
    string autoString = this.CustomerLastNameCell.AutoComplete("Smi");

    if (String.IsNullOrEmpty(autoString))
    {
        MessageBox.Show("No AutoComplete results were found.");
    }
    else
    {
        this.CustomerLastNameCell.Value2 = autoString;
    }
}

.NET Framework Security

See Also

Reference

XmlMappedRange Interface

Microsoft.Office.Tools.Excel Namespace