开发者

How to focus or select a cell in Excel

How to focus a cell in Excel VSTO using C# or to select first cell开发者_StackOverflow using C# in VSTO?


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.


To select the A2 cell, for example:

Excel.Worksheet Worksheet = excel.ActiveWorkbook.ActiveSheet;
Worksheet.get_Range([1,2], System.Reflection.Missing.Value).Select();


 Excel.Application ExcelApp = (Excel.Application)Marshal.GetActiveObject("Excel.Application");
            Excel.Workbook book = ExcelApp.ActiveWorkbook;
            Excel.Worksheet sheet = book.ActiveSheet;
            Excel.Range ExcelRange = sheet.get_Range("A1");
            ExcelRange.Select();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜