NamedRange.InnerObject Property (2007 System)

Gets a Range that represents the underlying native object for the Microsoft.Office.Tools.Excel.NamedRange.

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 InnerObject As Range
'Usage
Dim instance As NamedRange 
Dim value As Range 

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

Property Value

Type: Range
A Range that represents the underlying native object for the Microsoft.Office.Tools.Excel.NamedRange.

Remarks

You can use the InnerObject property to access the underlying Range for the NamedRange and pass it to a method or property that expects a Range passed as a Range. For more information, see Programmatic Limitations of Host Items and Host Controls.

If the ExcelLocale1033Attribute attribute is set to false, methods and properties in Excel that expect a Range passed as an Object will throw an InvalidCastException if you pass in a NamedRange. In this case, you can use the InnerObject property to pass the underlying native object to these methods and properties.

The InnerObject property returns a Range that passes the locale ID (LCID) 1033 (English, United States) to Microsoft Office Excel for all locale-sensitive calls to the Excel object model if the ExcelLocale1033Attribute attribute is set to true. To get a Range that passes the locale ID (LCID) of the current thread to Microsoft Office Excel, use the static Unwrap method of the ExcelLocale1033Proxy class. For more information about localization issues in Excel, see Formatting Data in Excel with Various Regional Settings.

Examples

The following code example starts a series of day names and then creates a NamedRange to contain the series. It then uses the AutoFill(Range, XlAutoFillType) method to complete the series. AutoFill(Range, XlAutoFillType) requires a Range as a parameter.

This example is for a document-level customization.

Private Sub InnerRange()
    Me.Range("A1").Value2 = "Sunday" 
    Me.Range("A2").Value2 = "Monday" 
    Dim dayRange As Microsoft.Office.Tools.Excel.NamedRange = _
        Me.Controls.AddNamedRange(Me.Range("A1", "A7"), _
        "dayRange")
    Me.Range("A1", "A2").AutoFill(dayRange.InnerObject, _
        Excel.XlAutoFillType.xlFillDays)
End Sub
private void InnerRange()
{
    this.Range["A1", missing].Value2 = "Sunday";
    this.Range["A2", missing].Value2 = "Monday";
    Microsoft.Office.Tools.Excel.NamedRange dayRange = 
        this.Controls.AddNamedRange(this.Range["A1", "A7"],
        "dayRange");
    this.Range["A1", "A2"].AutoFill(dayRange.InnerObject,
        Excel.XlAutoFillType.xlFillDays);
}

.NET Framework Security

See Also

Reference

NamedRange Class

NamedRange Members

Microsoft.Office.Tools.Excel Namespace