Share via


NamedRange.Parse Method

Parses a range of data and breaks it into multiple cells.

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

Syntax

'Declaration
Function Parse ( _
    ParseLine As Object, _
    Destination As Object _
) As Object
Object Parse(
    Object ParseLine,
    Object Destination
)

Parameters

  • ParseLine
    Type: System.Object

    A string that contains left and right brackets to indicate where the cells should be split.

    For example, "[xxx][xxx]" would insert the first three characters into the first column of the destination range, and it would insert the next three characters into the second column.

    If this argument is omitted, Microsoft Office Excel guesses where to split the columns based on the spacing of the top left cell in the range. If you want to use a different range to guess the parse line, use a Microsoft.Office.Interop.Excel.Range object as the ParseLine argument. That range must be one of the cells that is being parsed. The ParseLine argument cannot be longer than 255 characters, including the brackets and spaces.

Return Value

Type: System.Object

Remarks

Distributes the contents of the NamedRange control to fill several adjacent columns. The NamedRange control can be no more than one column wide.

Examples

The following code example uses the Parse method to parse each group of digits in a set of telephone numbers from a NamedRange control named NamedRange1 into a new range of cells starting at cell D1.

This example is for a document-level customization.

Private Sub ParsePhoneNumbers()
        Me.Range("A1").Value2 = "'5555550100'" 
        Me.Range("A2").Value2 = "'2065550101'" 
        Me.Range("A3").Value2 = "'4255550102'" 
        Me.Range("A4").Value2 = "'4155550103'" 
        Me.Range("A5").Value2 = "'5105550104'" 

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

        ' Parse the phone numbers and insert them into  
        ' the range starting at D1.
        namedRange1.Parse("[XXX][XXX][XXXX]", Me.Range("D1"))
    End Sub
private void ParsePhoneNumbers()
{
    this.Range["A1"].Value2 = "'5555550100'";
    this.Range["A2"].Value2 = "'2065550101'";
    this.Range["A3"].Value2 = "'4255550102'";
    this.Range["A4"].Value2 = "'4155550103'";
    this.Range["A5"].Value2 = "'5105550104'";

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

    // Parse the phone numbers and insert them into  
    // the range starting at D1.
    namedRange1.Parse("[XXX][XXX][XXXX]",
        this.Range["D1"]);
}

.NET Framework Security

See Also

Reference

NamedRange Interface

Microsoft.Office.Tools.Excel Namespace