NamedRange.Parent Property (2007 System)
Gets the parent object of 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 Parent As Object
'Usage
Dim instance As NamedRange
Dim value As Object
value = instance.Parent
[BrowsableAttribute(false)]
public Object Parent { get; }
[BrowsableAttribute(false)]
public:
property Object^ Parent {
Object^ get ();
}
public function get Parent () : Object
Property Value
Type: System.Object
The parent object of the NamedRange control.
Examples
The following code example creates a NamedRange and then uses the Parent property to display the name of the parent Worksheet of the NamedRange.
This example is for a document-level customization.
Private parentNameRange As Microsoft.Office.Tools.Excel.NamedRange
Private Sub DisplayParentName()
parentNameRange = Me.Controls.AddNamedRange( _
Me.Range("B2"), "parentNameRange")
parentNameRange.Select()
Dim parentSheet As Excel.Worksheet = _
CType(Me.parentNameRange.Parent, Excel.Worksheet)
MessageBox.Show("The NamedRange is in worksheet: " & _
parentSheet.Name)
End Sub
Microsoft.Office.Tools.Excel.NamedRange parentNameRange;
private void DisplayParentName()
{
parentNameRange = this.Controls.AddNamedRange(
this.Range["B2", missing], "parentNameRange");
parentNameRange.Select();
Excel.Worksheet parentSheet =
(Excel.Worksheet)this.parentNameRange.Parent;
MessageBox.Show("The NamedRange is in worksheet: " +
parentSheet.Name);
}
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.