I'm developing an Excel add-in. I need to get the value from A1 cell, so I use this code
value = workbook.Worksheets[1].Range["A1:A1"].Value2;
This works great but if :
- Previous Cell value is "1"
- User types "2" but does not press Enter or Tab
- User activates ribbon pressing it's button
Value2 got from this code sample is "1" (previous value) not "2" (current value shown in cell but not validated). This is wrong in my situation, I need "2".
How can I fix this?
I tried forcing selection of another cell
Application.ActiveCell.Offset[1, 0].Select();
or
Application.ActiveSheet.Range["A2"].Select();
but no way.. "2" value is lost.
I also tried getting value from text area in toolbar ("2" is shown there) but don't know hoe to do!