Read the ActiveCell content in Excel using VSTO

前端 未结 3 1028
青春惊慌失措
青春惊慌失措 2021-01-23 00:01

I\'m trying to read the ActiveCell from within an Excel Add-in but not getting very far. Anyone any ideas?

Excel.Window W = this.Application.ActiveWindow as Exce         


        
3条回答
  •  攒了一身酷
    2021-01-23 00:19

    Do not use Activewindow. modified your code as follows Excel.Range R = this.Application.ActiveCell as Excel.Range; if (R != null) MessageBox.Show(R.Value2);

    Note: ActiveCell can be null if user have not chosen a cell in the active sheet.

提交回复
热议问题