ファイルを開いたときにファイルを変更するワードアドインとしてアプリケーションを作成したいと考えています。
だから私はビジュアルスタジオでワードアドインプロジェクトを作成しました.これは基本的に私が持っているコードです:
namespace WordAddIn1
{
public partial class ThisAddIn
{
private void Application_DocumentOpen(Microsoft.Office.Interop.Word.Document Doc)
{
MessageBox.Show("doc opened");
// do my stuff
}
#region VSTO generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InternalStartup()
{
this.Application.DocumentOpen += new Word.ApplicationEvents4_DocumentOpenEventHandler(Application_DocumentOpen);
}
#endregion
}
}
問題は、空の単語アプリケーションを起動して (word.exe をダブルクリック)、文書を開いた場合はうまく機能しますが、文書を開くと同時に単語アプリケーションを起動した場合 (.doc ファイルをダブルクリック) は機能しません。