Export (0) Print
Expand All
Expand Minimize

NamedRange.InnerObject Property

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

Namespace: Microsoft.Office.Tools.Excel
Assembly: Microsoft.Office.Tools.Excel (in microsoft.office.tools.excel.dll)

public Range InnerObject { get; }

Property Value

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

You can use the InnerObject property to access the underlying Microsoft.Office.Interop.Excel.Range for the NamedRange and pass it to a method or property that expects a Microsoft.Office.Interop.Excel.Range passed as a Microsoft.Office.Interop.Excel.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 Microsoft.Office.Interop.Excel.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 Microsoft.Office.Interop.Excel.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 Microsoft.Office.Interop.Excel.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 Data in Excel with Various Locales.

The following code example starts a series of day names and then creates a NamedRange to contain the series. It then uses the AutoFill method to complete the series. AutoFill requires a Microsoft.Office.Interop.Excel.Range as a parameter.

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);
}

Show:
© 2014 Microsoft