파일을 열 때 파일을 변경하는 단어 추가 기능으로 응용 프로그램을 만들고 싶습니다.열린 단어 파일 이벤트 잡기
그래서 나는 Visual Studio에서 단어 추가 기능 프로젝트를 생성하고, 이것은 내가 가지고있는 기본적으로 코드입니다 : 당신이 빈 단어 응용 프로그램을 시작하는 경우
가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 파일을 두 번 클릭하면) 문서가 열리지 않습니다.