views:

266

answers:

1

How to focus a cell in Excel VSTO using C#?

How to select first cell using C# in VSTO?

Please help with code...

+1  A: 

Here is one way:

Excel.Worksheet activeSheet = ThisAddIn.ExcelApplication.ActiveSheet;
var range = activeSheet.get_Range("A1", "A1");
range.Select();

ThisAddIn is the name of my test project.

Mikael Svenson
You can also add a reference to Microsoft.Office.Interop.Excel.Extensions; so that you can do var range = activeSheet.Range("A1"); in place of the 2nd line.
Anonymous Type