Second part of the Excel tutorial. In this lesson I will show You how to add a custom task pane to the add-in and how to write information to desired cell in a Excel worksheet.

I will continue to develop solution from Part 1.

1. Add a new folder named TaskPanes and then add new UserControl.

2. Open the designer for the UserControl and add a new TextBox and Button.

3. Click twice on the button to create an eventhandler and then fill it with proper code


Microsoft.Office.Interop.Excel.Worksheet _sheet = Globals.ThisAddIn.Application.ActiveSheet as Microsoft.Office.Interop.Excel.Worksheet;
 Range _range = _sheet.get_Range(_sheet.Cells[1, 1], _sheet.Cells[1, 1]);
 _range.Value2 = textBox1.Text;

4. Open ThisAddIn.cs and add a new  task pan object and initialize it in the ThisAddIn_Startup method.

5. Go to Your ribbon class and change the previously created btnDisplayAlert_OnAction hadler body.

6. Press F5 and test the Add-In. It should write text You typed in the TextBox to Excel Cell in the first column in the first row.

That’s it for the Part 2.