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

匿名 (未验证) 提交于 2019-12-03 02:30:02

问题:

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

How to select first cell using C# in VSTO?

Please help with code...

回答1:

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.



回答2:

To select the A2 cell, for example:

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


回答3:

 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(); 


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!