ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Range address from Excel in C# (https://www.excelbanter.com/excel-programming/349355-range-address-excel-c.html)

ojv[_2_]

Range address from Excel in C#
 
Hope this is the right forum, if not please indicate which is.

Have implemented a SelectionChange event for Excel in C# - code below:

private void SelectionChange(Excel.Range Target)
{
_currRng = Target;
_currWS = (Excel.Worksheet)_currRng.Worksheet;
_currWB = (Excel.Workbook)_currWS.Parent;
string address =
_currRng.get_Address(Missing.Value,Missing.Value,
Excel.XlReferenceStyle.xlA1 ,Missing.Value,Missing.Value);
lblWB.Text = _currWB.Name;
lblWS.Text = _currWS.Name;
lblAddress.Text = address;
}

Invariably address comes out with an empty string ("") in the routine above.
However, if I get the address with the same statement after the
'SelectionChange' procedure has completed I get the correct address. What am
I missing?

ojv


All times are GMT +1. The time now is 10:27 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com