O
Olivier B.
Hi,
I have an add-in button bar, and I want to retrieve the data of the active
cell when I clic on one of the buttons.
Here is the code :
********************************************************
//Gets a range object for the active cell
object activeCell = Application.GetProperty("ActiveCell");
string cellValue
=activeCell.GetType().InvokeMember("Value",BindingFlags.GetProperty,null,activeCell,new object[0]).ToString();
MessageBox.Show(cellValue);
********************************************************
It works fine as long as the user isn't editing the cell. If the cell
content is "AB" and that the user types "ABCDE" without commiting and clics
on the button, I get "AB" whereas I want to get "ABCDE".
What I would like to do is to programaticaly commit the cell change.
I tried to select an other cell and activate it, but the first one keeps the
edition cursor, and when I press Enter the datas are validated in the cell I
have activated.
**********************************************************
//Selects next cell
object nextCell =
activeCell.GetType().InvokeMember("Next",BindingFlags.GetProperty,null,activeCell,new object[0]);
//Activates the cell
nextCell.GetType().InvokeMember("Activate",BindingFlags.InvokeMethod,null,nextCell,new object[0]);
*********************************************************
I also tried to use SendKeys and passing the Enter value, but all I get is a
new line in the currently edited cell as if I had typed [ALT]+[ENTER] ...
***********************************************************
Application.SendKeys("~",false);
System.Windows.Forms.Application.DoEvents();
***********************************************************
Does anyone have an other idea ?
Thanks.
Olivier
I have an add-in button bar, and I want to retrieve the data of the active
cell when I clic on one of the buttons.
Here is the code :
********************************************************
//Gets a range object for the active cell
object activeCell = Application.GetProperty("ActiveCell");
string cellValue
=activeCell.GetType().InvokeMember("Value",BindingFlags.GetProperty,null,activeCell,new object[0]).ToString();
MessageBox.Show(cellValue);
********************************************************
It works fine as long as the user isn't editing the cell. If the cell
content is "AB" and that the user types "ABCDE" without commiting and clics
on the button, I get "AB" whereas I want to get "ABCDE".
What I would like to do is to programaticaly commit the cell change.
I tried to select an other cell and activate it, but the first one keeps the
edition cursor, and when I press Enter the datas are validated in the cell I
have activated.
**********************************************************
//Selects next cell
object nextCell =
activeCell.GetType().InvokeMember("Next",BindingFlags.GetProperty,null,activeCell,new object[0]);
//Activates the cell
nextCell.GetType().InvokeMember("Activate",BindingFlags.InvokeMethod,null,nextCell,new object[0]);
*********************************************************
I also tried to use SendKeys and passing the Enter value, but all I get is a
new line in the currently edited cell as if I had typed [ALT]+[ENTER] ...
***********************************************************
Application.SendKeys("~",false);
System.Windows.Forms.Application.DoEvents();
***********************************************************
Does anyone have an other idea ?
Thanks.
Olivier