GANoob4eva
GANoob4eva

Reputation: 13

C# Excel 2013 Addin, write value to the selected cell

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

Answers (1)

Alex Butenko
Alex Butenko

Reputation: 3764

Almost the same as you get the value:

Excel.Range currentSelectedCell = Globals.ThisWorkbook.Application.ActiveCell;
currentSelectedCell.Value = myTextbox.Text;

Upvotes: 1

Related Questions