Share via


NamedRange.Width 屬性

取得 NamedRange 控制項的寬度 (以點為單位)。

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

語法

'宣告
ReadOnly Property Width As Object
Object Width { get; }

屬性值

型別:System.Object
NamedRange 控制項的寬度 (以點為單位)。

範例

下列程式碼範例會建立 NamedRange,然後使用 Width 和 Height 屬性顯示 NamedRange 的寬度和高度。

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

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

Private Sub DisplayHeightAndWidth()
    heightWidthRange = Me.Controls.AddNamedRange( _
        Me.Range("B4"), "heightWidthRange")
    heightWidthRange.Select()
    MessageBox.Show("The NamedRange control is " & _
        Me.heightWidthRange.Width & " points wide and " & _
        Me.heightWidthRange.Height & " points high.")
End Sub
Microsoft.Office.Tools.Excel.NamedRange heightWidthRange;
private void DisplayHeightAndWidth()
{
    heightWidthRange = this.Controls.AddNamedRange(
        this.Range["B4"], "heightWidthRange");
    heightWidthRange.Select();
    MessageBox.Show("The NamedRange control is " +
    this.heightWidthRange.Width + " points wide and " +
    this.heightWidthRange.Height + " points high.");
}

.NET Framework 安全性

請參閱

參考

NamedRange 介面

Microsoft.Office.Tools.Excel 命名空間