470,849 Members | 1,590 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,849 developers. It's quick & easy.

Can events be hooked to MS Word?

I am opening a MS Word document using the following C# code.

Expand|Select|Wrap|Line Numbers
  1. Word.ApplicationClass WordApp = new Word.ApplicationClass();
  3. // Use the open file dialog to choose a word document
  4. if (this.openFileDialog1.ShowDialog() == DialogResult.OK)
  5. {
  6. object fileName = openFileDialog1.FileName;
  7. object readOnly = false;
  8. object isVisible = true;
  10. //Here is the way to handle parameters you don't care about in .NET
  11. object missing = System.Reflection.Missing.Value;
  13. //Make word visible, so you can see what's happening
  14. WordApp.Visible = true;
  16. //Open the document that was chosen by the dialog
  17. Word.Document aDoc = WordApp.Documents.Open(ref fileName, ref missing,ref
  18. readOnly, ref missing, ref missing, ref missing, ref missing, ref missing,
  19. ref missing, ref missing, ref missing, ref isVisible);
  21. //Activate the document so it shows up in front
  22. aDoc.Activate();
  23. }
This works fine and it opens the document in MS Word separate from the C#
application. Is there a way of hooking an event to the document object (aDoc)
so that when the word document is closed the C# application can react to the

Apr 10 '06 #1
0 865

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Rick Strahl [MVP] | last post: by
15 posts views Thread by Rhy Mednick | last post: by
reply views Thread by Scott McChesney | last post: by
1 post views Thread by Larry Lard | last post: by
4 posts views Thread by Jeff User | last post: by
7 posts views Thread by nick.fletcher | last post: by
8 posts views Thread by earth | last post: by
15 posts views Thread by damiensawyer | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.