How to get the “KeyPress” event from a Word 2010 Addin (developed in C#)?

后端 未结 2 1237
礼貌的吻别
礼貌的吻别 2020-11-30 12:45

How can I \"catch\" the KeyPress event from a Word 2010 Addin developed in C#?

Note: I\'m not looking for \"complex\" solutions like hooking stuff, but for the nice

2条回答
  •  死守一世寂寞
    2020-11-30 13:10

    You might try to use the Excel WebBrowser Control instead of the System.Windows.Forms WebBrowser; it handles special key forwarding as TAB, DEL, CTRL+V, etc.

    For that change the WebBrowser contructor from

    new System.Windows.Forms.WebBrowser();
    

    to

    new Microsoft.Office.Tools.Excel.Controls.WebBrowser();  
    

    You would need to add references to your project: Project/Add Reference/Extensions select Microsoft.Tools.Outlook & Microsoft.Tools.Outlook.v4.0.Utilities

提交回复
热议问题