Worksheet.Parent Property (2007 System)

Gets the parent object for the worksheet.

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 Worksheet 
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 for the worksheet.

Examples

The following code example uses the Parent property to determine whether the current Worksheet has a parent. If the current Worksheet has a parent, then name of the parent workbook is displayed.

This example is for a document-level customization.

Private Sub DisplayParent()
    If Not (Me.Parent Is Nothing) Then 
        Dim book As Excel.Workbook = _
            CType(Me.Parent, Excel.Workbook)
        MsgBox("The parent workbook for this worksheet is: " & _
            book.Name)
    Else
        MsgBox("This worksheet has no parent.")
    End If 
End Sub
private void DisplayParent()
{
    if (this.Parent != null)
    {
        Excel.Workbook book = (Excel.Workbook)this.Parent;
        MessageBox.Show("The parent workbook for this worksheet is: " + 
            book.Name);
    }
    else
    {
        MessageBox.Show("This worksheet has no parent.");
    }
}

.NET Framework Security

See Also

Reference

Worksheet Class

Worksheet Members

Microsoft.Office.Tools.Excel Namespace