473,657 Members | 2,546 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

need Document Close event handler

Hi, Group,

I am using C# program to launch a Word document in Word 2003. My C# program
will be sitting on "top most" while document opened. I would like to hook up
an event when Word document has been closed (not Word application), my
program will be closed automatically too.

I can't find the "Close" event in ActiveDocument. There are events for "New"
and "Open". How do I create event handler for document closed?

Thanks.
Eric
Nov 16 '05 #1
2 7800
Eric Li wrote:
I am using C# program to launch a Word document in Word 2003. My C# program
will be sitting on "top most" while document opened. I would like to hook up
an event when Word document has been closed (not Word application), my
program will be closed automatically too.

I can't find the "Close" event in ActiveDocument. There are events for "New"
and "Open". How do I create event handler for document closed?


Hi Eric,

the DocumentClass offers a DocumentEvents_ Event_Close. The following
code works for me (Word 2003 and PIAs installed):

private void button1_Click(o bject sender, System.EventArg s e)
{
ApplicationClas s app = new ApplicationClas s();
object miss = System.Type.Mis sing;
DocumentClass doc = (DocumentClass) app.Documents.A dd(ref miss, ref
miss, ref miss, ref miss);
app.Visible = true;
doc.DocumentEve nts_Event_Close +=new
DocumentEvents_ CloseEventHandl er(doc_Document Events_Event_Cl ose);
}

private void doc_DocumentEve nts_Event_Close ()
{
MessageBox.Show ("Close event");
}

Cheers

Arne Janning
Nov 16 '05 #2
Hi, Arne,

Great! I will give it a try. Thanks.
Eric

"Arne Janning" <sp************ *****@msn.com> wrote in message
news:uH******** ******@TK2MSFTN GP09.phx.gbl...
Eric Li wrote:
I am using C# program to launch a Word document in Word 2003. My C# program will be sitting on "top most" while document opened. I would like to hook up an event when Word document has been closed (not Word application), my
program will be closed automatically too.

I can't find the "Close" event in ActiveDocument. There are events for "New" and "Open". How do I create event handler for document closed?


Hi Eric,

the DocumentClass offers a DocumentEvents_ Event_Close. The following
code works for me (Word 2003 and PIAs installed):

private void button1_Click(o bject sender, System.EventArg s e)
{
ApplicationClas s app = new ApplicationClas s();
object miss = System.Type.Mis sing;
DocumentClass doc = (DocumentClass) app.Documents.A dd(ref miss, ref
miss, ref miss, ref miss);
app.Visible = true;
doc.DocumentEve nts_Event_Close +=new
DocumentEvents_ CloseEventHandl er(doc_Document Events_Event_Cl ose);
}

private void doc_DocumentEve nts_Event_Close ()
{
MessageBox.Show ("Close event");
}

Cheers

Arne Janning

Nov 16 '05 #3

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

Similar topics

8
2018
by: George Hester | last post by:
In a page I have when the user left-clicks the page a Input box for a form gets the focus. But if the user right-clicks the page the Input box is not getting the focus. I'd like the Input box to get the focus no matter where on the page the user clicks be it right-click or left-click. Right now there is no context menu when the user right-clicks. Do you think that's the problem? Any ideas how to get this right-click left-click Input box...
1
1449
by: lawrence | last post by:
I'm trying to gain a better understanding of javascript by studying examples. I noticed this in an online tutorial. I don't get the use of "this". >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> You might want to add some event handler for an event to an element to which there is already an event handler attached. That is possible by storing the old event handler somewhere and then writing a new function which calls the old event handler.
106
6424
by: xtra | last post by:
Hi Folk I have about 1000 procedures in my project. Many, many of them are along the lines of function myfuntion () as boolean on error goto er '- Dim Dbs as dao.database Dim Rst as dao.recordset
7
4619
by: Sandy | last post by:
Hello - I have a form that when submitted checks the database and if the username is already taken, a label shows indicating same. I need to make that label NOT visible after the user clicks in the username textbox to change the name. Any help will be greatly appreciated!
3
1471
by: Jason James | last post by:
Hi all, I have an application that needs to print numerous documents of different styles (either to the printer or print preview dialog). I have selected which document type to print by using a select statement in the the PrintDocument.PrintPage
2
17391
by: pbd22 | last post by:
Hi. I have an event handler in VB.NET that gets called several times. The output of the event handler is XML that is being called by an xmlhttp request from the client. I am using a stringbuilder to create the XML document by appending the various parts: sbhtml.Append("<Some XML Tag>")
7
2913
by: Sin Jeong-hun | last post by:
I have a dialog form which pops up from the main window using the ShowDialog() method. this dialog has no or button, and it has quite a lot of controls on it. Now, I want to close this dialog form when the user presses the escape key, but that's only when no control on the form is responsible for the escape key. For example, it has a ComboBox control, and a user can press the escape key just to close the drop down list that is being...
2
1624
by: registry | last post by:
<%@Language="VBSCRIPT" CODEPAGE="1252"%> <html> <head> <title>Registry Network Hospital Detail</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <script language="JavaScript" type="text/JavaScript"> <!-- function MM_reloadPage(init) { //reloads the window if Nav4 resized
0
8425
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8845
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8743
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7355
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6177
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5647
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2745
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1973
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1736
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.