NamedRange.AutoComplete Method (2007 System)

Gets an AutoComplete match from the list.

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

Syntax

'Declaration
Public Function AutoComplete ( _
    String As String _
) As String
'Usage
Dim instance As NamedRange 
Dim String As String 
Dim returnValue As String 

returnValue = instance.AutoComplete(String)
public string AutoComplete(
    string String
)
public:
String^ AutoComplete(
    String^ String
)
public function AutoComplete(
    String : 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 demonstrates how to use the AutoComplete method. The example first sets the value of cell A1 to the string "Martha lives on a vineyard" and creates a NamedRange control in cell A2. The example then uses the AutoComplete method to obtain an AutoComplete match from the substring "Ma" and places the matching value in the NamedRange.

This example is for a document-level customization.

Private Sub FindMarthaInTheRange()
    Me.Range("A1").Value2 = "Martha lives on a vineyard" 

    Dim namedRange1 As Microsoft.Office.Tools.Excel.NamedRange _
        = Me.Controls.AddNamedRange(Me.Range("A2"), _
        "namedRange1")

    namedRange1.AddComment("This is Martha's range.")
    namedRange1.Value2 = namedRange1.AutoComplete("Ma")

    If MessageBox.Show("Clear the range?", "Test", _
        MessageBoxButtons.YesNo) = DialogResult.Yes Then
        namedRange1.Clear()
    End If 
End Sub
private void FindMarthaInTheRange()
{
    this.Range["A1", missing].Value2 = "Martha lives on a vineyard";

    Microsoft.Office.Tools.Excel.NamedRange namedRange1 =
        this.Controls.AddNamedRange(this.Range["A2", missing],
        "namedRange1");

    namedRange1.AddComment("This is Martha's range.");
    namedRange1.Value2 = namedRange1.AutoComplete("Ma");

    if (MessageBox.Show("Clear the range?", "Test",
        MessageBoxButtons.YesNo) == DialogResult.Yes)
    {
        namedRange1.Clear();
    }
}

.NET Framework Security

See Also

Reference

NamedRange Class

NamedRange Members

Microsoft.Office.Tools.Excel Namespace