473,324 Members | 2,581 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

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();
  2.  
  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;
  9.  
  10. //Here is the way to handle parameters you don't care about in .NET
  11. object missing = System.Reflection.Missing.Value;
  12.  
  13. //Make word visible, so you can see what's happening
  14. WordApp.Visible = true;
  15.  
  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);
  20.  
  21. //Activate the document so it shows up in front
  22. aDoc.Activate();
  23. }
  24.  
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
event?

Thanks
Kobus
Apr 10 '06 #1
0 920

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Rajesh.V | last post by:
I have made a custom control in asp.net using webcontrols, and am raising my event. I find that if no control is hooked into the event it goes for a toss. I tried to find length of the delegate...
3
by: Rick Strahl [MVP] | last post by:
I'm working on an app that's using the WebBrowser control. I got the control working fine, hooking to the document object. But I've run into a major issue with hooking the Document events....
15
by: Rhy Mednick | last post by:
I have a class (let's call it ClassA) that I've written which has events. In another class (let's call it ClassB) I create a collection of ClassA objects. In a third class (ClassC) I create a...
0
by: Scott McChesney | last post by:
I have a problem I hope you folks can help me with. I have an application that is using a tab-based interface, with the ability for users to drag an item from a ListBox onto the tab control. ...
1
by: Larry Lard | last post by:
I know that when I define my own class with an event, eg Public Class Foo Public Event Bar .... behind the scenes VB creates a hidden (from IntelliSense) delegate class BarEventHandler and...
4
by: Jeff User | last post by:
Hi I tryed to solve this problem over in the framework.asp group, but still am having trouble. Hope someone here can help. using .net 1.1, VS 2003 and C# I have an asp.DataGrid control with a...
7
by: nick.fletcher | last post by:
I have a custom collection which derives from Collection<which stores a number of objects. Before each item is added to the collection - an event which it exposes is hooked by the collection and...
8
by: earth | last post by:
If I have a class call it ClassA which is an aggregate of ClassB. ClassA delegates to ClassB (I mean that in the English sense of the word not in the C# reserved word sense). So for instance...
15
by: damiensawyer | last post by:
Hi, I am creating a class (from a base class) that needs to trigger events (code at bottom). I am instatiating the classes and wiring up the events as follows. clsDetermineConnection oDC =...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.