Share via


NamedRange.Worksheet Property

Definition

Gets a Worksheet that represents the worksheet that contains the NamedRange control.

public:
 property Microsoft::Office::Interop::Excel::Worksheet ^ Worksheet { Microsoft::Office::Interop::Excel::Worksheet ^ get(); };
public Microsoft.Office.Interop.Excel.Worksheet Worksheet { get; }
member this.Worksheet : Microsoft.Office.Interop.Excel.Worksheet
Public ReadOnly Property Worksheet As Worksheet

Property Value

A Worksheet that represents the worksheet that contains the NamedRange control.

Examples

The following code example displays the name of the worksheet that contains a NamedRange.

This example is for a document-level customization.

private void DisplayWorksheetName()
{
    Microsoft.Office.Tools.Excel.NamedRange namedRange1 =
        this.Controls.AddNamedRange(this.Range["A1"],
        "namedRange1");
    namedRange1.Worksheet.Name = "Sales";
    MessageBox.Show("The NamedRange is on worksheet " +
        namedRange1.Worksheet.Name);
}
Private Sub DisplayWorksheetName()
    Dim namedRange1 As Microsoft.Office.Tools.Excel.NamedRange _
        = Me.Controls.AddNamedRange(Me.Range("A1"), _
        "namedRange1")
    namedRange1.Worksheet.Name = "Sales"
    MessageBox.Show("The NamedRange is on worksheet " & _
        namedRange1.Worksheet.Name)
End Sub

Applies to