Share via


NamedRange.AddressLocal 屬性

取得採用使用者語言的 NamedRange 控制項範圍參照。

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

語法

'宣告
ReadOnly Property AddressLocal As NamedRange_AddressLocalType
NamedRange_AddressLocalType AddressLocal { get; }

屬性值

型別:Microsoft.Office.Tools.Excel.NamedRange_AddressLocalType
字串,表示採用使用者語言和 R1C1 樣式或 A1 樣式標記的 NamedRange 控制項範圍參照。

備註

AddressLocal 屬性的用意是要與下列參數一起使用。

參數

描述

RowAbsolute

true 表示以絕對參照的形式傳回列。 預設值是 true。

ColumnAbsolute

true 表示以絕對參照的形式傳回欄。 預設值是 true。

ColumnAbsolute

其中一個 XlReferenceStyle 值。

External

true 代表傳回外部參照,false 代表傳回本機參照。 預設值是 false。

RelativeTo

定義起點的 Range。 如果 RowAbsolute 和 ColumnAbsolute 為 false,且 ReferenceStyle 為 xlR1C1,則必須加入起點做為相對參考位址。

如果您嘗試在不指定任何參數的情況下使用 AddressLocal,則 AddressLocal 會得到 NamedRange_AddressLocalType 物件,但該物件是 Visual Studio 基礎結構的一部分,並不適合直接在程式碼中使用。

如果參照包含一個以上的儲存格,則 RowAbsolute 和 ColumnAbsolute 會套用至所有的列和欄。

選擇性參數

如需選擇性參數的詳細資訊,請參閱Office 方案中的選擇性參數

範例

下列程式碼範例會建立 NamedRange,然後以四種格式顯示 NamedRange 的位址。 如果範例是在使用德文支援的系統上執行,則此範例會顯示位址字串 "$A$2"、"$A2"、"Z2S2" 和 "Z[-1]S[-1]"。

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

    Private Sub DisplayAddressLocal()
        'Change system settings to German and test this.
        Dim namedRange1 As Microsoft.Office.Tools.Excel.NamedRange _
            = Me.Controls.AddNamedRange(Me.Range("A2", "C4"), _
            "namedRange1")

        ' The following code will display "$A$2".
        MessageBox.Show(namedRange1.AddressLocal(True, True, _
            Excel.XlReferenceStyle.xlA1, False, ))

        ' The following code will display "$A2".
        MessageBox.Show(namedRange1.AddressLocal(False, True, _
            Excel.XlReferenceStyle.xlA1, False, ))

        ' The following code will display "Z2S2".
        MessageBox.Show(namedRange1.AddressLocal(True, True, _
            Excel.XlReferenceStyle.xlR1C1, False, ))

        ' The following code will display "Z[-1]S[-1]".
        MessageBox.Show(namedRange1.AddressLocal(False, False, _
            Excel.XlReferenceStyle.xlR1C1, False, Me.Cells(3, 3)))
    End Sub

private void DisplayAddressLocal()
{
    //Change system settings to German and test this.
    Microsoft.Office.Tools.Excel.NamedRange namedRange1 =
        this.Controls.AddNamedRange(this.Range["A2", "C4"],
        "namedRange1");

    // The following code will display "$A$2".
    MessageBox.Show(namedRange1.AddressLocal[true,
        true, Excel.XlReferenceStyle.xlA1, false]);

    // The following code will display "$A2".
    MessageBox.Show(namedRange1.AddressLocal[false,
        true, Excel.XlReferenceStyle.xlA1, false]);

    // The following code will display "Z2S2".
    MessageBox.Show(namedRange1.AddressLocal[true,
         true, Excel.XlReferenceStyle.xlR1C1, false]);

    // The following code will display "Z[-1]S[-1]".
    MessageBox.Show(namedRange1.AddressLocal[false,
        false, Excel.XlReferenceStyle.xlR1C1, false, this.Cells[3, 3]]);
}

這是示範應用程式層級增益集的版本。

.NET Framework 安全性

請參閱

參考

NamedRange 介面

Microsoft.Office.Tools.Excel 命名空間