NamedRange.AddressLocal Property (2007 System)

Gets the range reference for the NamedRange control in the language of the user.

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 AddressLocal As NamedRange._AddressLocalType
'Usage
Dim instance As NamedRange 
Dim value As NamedRange._AddressLocalType 

value = instance.AddressLocal
[BrowsableAttribute(false)]
public NamedRange._AddressLocalType AddressLocal { get; }
[BrowsableAttribute(false)]
public:
property NamedRange._AddressLocalType^ AddressLocal {
    NamedRange._AddressLocalType^ get ();
}
public function get AddressLocal () : NamedRange._AddressLocalType

Property Value

Type: Microsoft.Office.Tools.Excel.NamedRange._AddressLocalType
A string that represents the range reference of the NamedRange control in the language of the user and in R1C1-stye or A1-style notation.

Remarks

The AddressLocal property is intended to be used with the following parameters.

Parameter

Description

RowAbsolute

true to return the row as an absolute reference. The default value is true.

ColumnAbsolute

true to return the column as an absolute reference. The default value is true.

ColumnAbsolute

One of the XlReferenceStyle values.

External

true to return an external reference; false to return a local reference. The default value is false.

RelativeTo

A Range that defines the starting point. If RowAbsolute and ColumnAbsolute are false, and ReferenceStyle is xlR1C1, you must include a starting point for the relative reference.

If you attempt to use AddressLocal without specifying any parameters, AddressLocal will get a NamedRange._AddressLocalType object that is part of the Visual Studio Tools for Office infrastructure and is not intended to be used directly from your code.

If the reference contains more than one cell, RowAbsolute and ColumnAbsolute apply to all rows and columns.

Optional Parameters

For information on optional parameters, see The Variable missing and Optional Parameters in Office Solutions.

Examples

The following code example creates a NamedRange and then displays the address of the NamedRange in four formats. If the example is run on a system using German language support, the example will display the address strings "$A$2", "$A2", "Z2S2", and "Z[-1]S[-1]".

This version is for a document-level customization.

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, missing]);

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

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

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

This version is for an application-level add-in.

Private Sub DisplayAddressLocal()
    Dim vstoWorksheet As Worksheet = CType( _
        Me.Application.ActiveWorkbook.Worksheets(1),  _
        Excel.Worksheet).GetVstoObject()
    'Change system settings to German and test this. 
    Dim namedRange1 As NamedRange _
        = vstoWorksheet.Controls.AddNamedRange(vstoWorksheet.Range("A2", "C4"), _
        "namedRange1")

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

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

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

    ' The following code will display "Z[-1]S[-1]".
    System.Windows.Forms.MessageBox.Show(namedRange1.AddressLocal(False, False, _
        Excel.XlReferenceStyle.xlR1C1, False, vstoWorksheet.Cells(3, 3)))
End Sub
private void DisplayAddressLocal()
{
    Worksheet vstoWorksheet = ((Excel.Worksheet)
        this.Application.ActiveWorkbook.Worksheets[1]).GetVstoObject();
    //Change system settings to German and test this.
    NamedRange namedRange1 =
        vstoWorksheet.Controls.AddNamedRange(
        vstoWorksheet.Range["A2", "C4"],
        "namedRange1");

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

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

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

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

.NET Framework Security

See Also

Reference

NamedRange Class

NamedRange Members

Microsoft.Office.Tools.Excel Namespace

Change History

Date

History

Reason

July 2008

Added a version of the code example for an application-level add-in.

SP1 feature change.