Reputation: 13
Trying to write a string to the currently active cell in Excel 2013, I am using Visual Studio 2013, C# to create an Office add-in.
I could reached the part where I can get the value in the currently selected cell inside my Windows Forms window, but I have trouble writing it back Excel.
Excel.Range currentSelectedCell = Globals.ThisWorkbook.Application.ActiveCell;
//output to an object
object cellValue = currentSelectedCell.Value;
//convert object to a string that can be displayed
Convert.ToInt32(cellValue);
//finally display the string inside a textbox
myTextbox.Text = cellValue.ToString();
// how to get myTextbox.Text to> object to> Globals.ThisWorkbook.Application.ActiveCell ?
Any help is welcomed.
Upvotes: 1
Views: 946
Reputation: 3764
Almost the same as you get the value:
Excel.Range currentSelectedCell = Globals.ThisWorkbook.Application.ActiveCell;
currentSelectedCell.Value = myTextbox.Text;
Upvotes: 1