NamedRange.Text Property (2007 System)

Gets the text for the NamedRange control.

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

Syntax

'Declaration
<BrowsableAttribute(False)> _
Public ReadOnly Property Text As Object
'Usage
Dim instance As NamedRange 
Dim value As Object 

value = instance.Text
[BrowsableAttribute(false)]
public Object Text { get; }
[BrowsableAttribute(false)]
public:
property Object^ Text {
    Object^ get ();
}
public function get Text () : Object

Property Value

Type: System.Object
The text for the NamedRange control.

Remarks

Returns nulla null reference (Nothing in Visual Basic) for NamedRange controls with multiple cells.

Examples

The following code example compares how the Text and Value2 properties differ for cells that contain formatted numbers.

This example is for a document-level customization.

Private Sub DisplayText()
    Dim namedRange1 As Microsoft.Office.Tools.Excel.NamedRange _
        = Me.Controls.AddNamedRange(Me.Range("A1"), _
        "namedRange1")
    namedRange1.Value2 = 223

    namedRange1.Value2 = 1198.3
    namedRange1.NumberFormat = "$#,##0" 

    ' Displays "1198.3".
    MessageBox.Show("The Value2 value is: " & _
        namedRange1.Value2.ToString())

    ' Displays "$1,198".
    MessageBox.Show("The Text value is: " & _
        namedRange1.Text.ToString())
End Sub
private void DisplayText()
{
    Microsoft.Office.Tools.Excel.NamedRange namedRange1 =
        this.Controls.AddNamedRange(this.Range["A1", missing],
        "namedRange1");
    namedRange1.Value2 = 223;

    namedRange1.Value2 = 1198.3;
    namedRange1.NumberFormat = "$#,##0";

    // Displays "1198.3".
    MessageBox.Show("The Value2 value is: " +
        namedRange1.Value2.ToString());

    // Displays "$1,198".
    MessageBox.Show("The Text value is: " +
        namedRange1.Text.ToString());
}

.NET Framework Security

See Also

Reference

NamedRange Class

NamedRange Members

Microsoft.Office.Tools.Excel Namespace