当前位置: 动力学知识库 > 问答 > 编程问答 >

c# - How to check if an Excel document cell is being edited

问题描述:

In C#, how can I check if within an Excel document there's a general selected cell and this cell is also active for editing its value?

Manually, in Excel you can select a single cell by a single left click; you can start editing it by double clicking the cell... the 2nd situation is what I need to check programmatically.

NEW EDIT: The problem is that if a cell is being edited, then Excel is stuck and a crash occurs accessing the Active Workbook. So, if I can previously determine if cell is being edited I don't proceed accessing the workbook.

网友答案:

As SimonMᶜKenzie suggested, I found a trick to solve my problem by following this document...

The solution I've implemented is this one:

 bool IsCellBeingEdited(Excel.Application excelApp)
 {
   CORE.CommandBarControl cbc = excelApp.CommandBars.FindControl(1, 18, System.Type.Missing, System.Type.Missing);
   return cbc != null && !cbc.Enabled;
 }
分享给朋友:
您可能感兴趣的文章:
随机阅读: