NamedRange.CurrentRegion 屬性

取得 Microsoft.Office.Interop.Excel.Range 物件,表示目前的區域。

命名空間:  Microsoft.Office.Tools.Excel
組件:  Microsoft.Office.Tools.Excel (在 Microsoft.Office.Tools.Excel.dll 中)

語法

'宣告
ReadOnly Property CurrentRegion As Range
Range CurrentRegion { get; }

屬性值

型別:Microsoft.Office.Interop.Excel.Range
Microsoft.Office.Interop.Excel.Range 物件,表示目前的區域。

備註

目前區域是任何空白列或空白欄組合所繫結的範圍。

這個屬性無法在受保護的工作表中使用。

範例

下列程式碼範例會建立 NamedRange,並將值 123 填入。 然後它會將目前的區域著色成綠色,也就是由空白的欄與列界定的區域。

這是示範文件層級自訂的範例。

Private currentRegionRange As Microsoft.Office.Tools.Excel.NamedRange

Private Sub ColorCurrentRegion()
    currentRegionRange = Me.Controls.AddNamedRange( _
        Me.Range("C3", "E5"), "currentRegionRange")
    currentRegionRange.Value2 = "123"

    ' Set the color of the region to the RGB value for green.
    Me.currentRegionRange.CurrentRegion.Interior.Color = &HFF00
End Sub
Microsoft.Office.Tools.Excel.NamedRange currentRegionRange;
private void ColorCurrentRegion()
{
    currentRegionRange = this.Controls.AddNamedRange(
        this.Range["C3", "E5"], "currentRegionRange");
    currentRegionRange.Value2 = "123";

    // Set the color of the region to the RGB value for green.
    this.currentRegionRange.CurrentRegion.Interior.Color = 0xFF00;
} 

.NET Framework 安全性

請參閱

參考

NamedRange 介面

Microsoft.Office.Tools.Excel 命名空間