0

概念実証を行うために、NetOffice v1.7.3 で Word アドイン プロジェクトを作成しました。

2 つのイベント (OnStartupComplete と OnDisconnection) が接続されていることがわかります。

<!-- language: c# -->
public class Addin : Word.Tools.COMAddin
{
        public Addin()
        {
            this.OnStartupComplete += new OnStartupCompleteEventHandler(Addin_OnStartupComplete);
            this.OnDisconnection += new OnDisconnectionEventHandler(Addin_OnDisconnection);
        }
}

New Document イベント、Save Document イベント、Close Document イベントをリッスンする方法を知っていますか?

ネットでこのコードを見つけましたが、NetOffice での実行方法がわかりません。

<!-- language: c# -->
private void ThisAddIn_Startup(object sender, System.EventArgs e) 
{
    Microsoft.Office.Interop.Word.ApplicationEvents2_Event wdEvents2 = (Microsoft.Office.Interop.Word.ApplicationEvents2_Event) this.Application;
    wdEvents2.NewDocument += new Word.ApplicationEvents2_NewDocumentEventHandler(wdEvents2_NewDocument); 
}

void wdEvents2_NewDocument(Word.Document Doc) 
{
    MessageBox.Show("New Document Fires.", "New Document", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); 
}


Dat よろしくお願いします。

4

1 に答える 1