473,772 Members | 2,412 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Excel/PowerPoint Quit event

I'm working with Office Application objects in a client/server
WinForm application which allows the user to access remotely
stored files. When the user opens the remote file, it is
downloaded to their machine, and it is opened in the appropriate
Office app.

I've hooked the various BeforeSave events to let me know if/when
they've made modifications to the file, so I can mark it as dirty.
However, I would like to know when the Office application has
terminated, so that I can then upload dirty files back to the
remote server. Word.Applicatio n has a Quit event in its parent
interface ApplicationEven ts4_Event, so I can hook that. However,
I haven't seen a similar Quit event in the Excel and PowerPoint
objects. Anybody know where it is, or if it exists?

(I'd also like to know when the Office applications quit so that
I can remove the COM references and null out the variables that
point to them.)

Oh, and I can't use the BeforeClose/Close events, because if
the user hits the Close Window button on the frame of the
application, then the document is closed it is saved. (Oddly enough.)

Thanks,
Harold

Nov 17 '05 #1
2 3207
Harold,

Since the office applications are processes in themselves, you could get
the Process instance that represents the process that you started, then call
the WaitForExit method, blocking until the application exits. Of course,
you don't want to keep your application hung up while this is happening, so
I would recommend doing this in another thread while waiting (which can then
fire an event upon completion).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

<hs****@gmail.c om> wrote in message
news:11******** **************@ g44g2000cwa.goo glegroups.com.. .
I'm working with Office Application objects in a client/server
WinForm application which allows the user to access remotely
stored files. When the user opens the remote file, it is
downloaded to their machine, and it is opened in the appropriate
Office app.

I've hooked the various BeforeSave events to let me know if/when
they've made modifications to the file, so I can mark it as dirty.
However, I would like to know when the Office application has
terminated, so that I can then upload dirty files back to the
remote server. Word.Applicatio n has a Quit event in its parent
interface ApplicationEven ts4_Event, so I can hook that. However,
I haven't seen a similar Quit event in the Excel and PowerPoint
objects. Anybody know where it is, or if it exists?

(I'd also like to know when the Office applications quit so that
I can remove the COM references and null out the variables that
point to them.)

Oh, and I can't use the BeforeClose/Close events, because if
the user hits the Close Window button on the frame of the
application, then the document is closed it is saved. (Oddly enough.)

Thanks,
Harold

Nov 17 '05 #2
Thanks for the reply, Nicholas. I played around with the Process class
as per your suggestion, and indeed it all works beautifully, except...
(knew that was coming, didn't'cha?)

Ok, I seem to have a paradox. In order for the Excel process to
terminate (so my waiting thread unblocks from the WaitForExit()
call), I have to release all references to the Excel.Applicati on
instance, including using the Marshal.Release ComObject().
If I do this, Excel dies a peaceful death when the user
closes it, and the WaitForExit() call returns and I can then perform
clean up. Beautiful.

But, if I release all references to the Excel.Applicati on, then the
BeforeSaveEvent that I've hooked to let me know that the workbook
was saved no longer receives events. So now I can't tell if the
file was saved (using that event). I could use file modification time,
I
guess, but I was wondering if there was another way out:
ReleaseComObjec t(): good for WaitForExit(), bad for BeforeSave
no ReleaseComObjec t(): bad for WaitForExit(), good for BeforeSave

Many thanks indeed,
Harold

Nov 17 '05 #3

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

Similar topics

6
3410
by: C Williams | last post by:
Hi, I am writing some VB.NET code that compiles to a dll. There is some code within it that manipulates Powerpoint 2003. The dll I am writing is for smart tags, and I am having trouble because sometimes Powerpoint is remaining running (powerpnt.exe in Task Manager). One action of my smart tags calls InsertChart (code below). The designated line causes powerpoint to remain running even after the user has manually closed the...
6
12507
by: Matthew Wieder | last post by:
I have the following requirements: Build a stand-alone C# application that asks the user to click in a cell in an Excel spreadsheet, and then displays the address of that cell in the C# application. It seems simple enough, but the problem I'm encountering is as follows: In order for the user to select the cell from Excel, they must first click once on the Excel window to give it focus and then their second click is what changes the cell...
8
7077
by: Rut | last post by:
Does anyone know how to start powerpoint from vb.net without the ppt screen appearing. I want to keep it hidden? Using this code: Try pp = New PowerPoint.Application pp.Visible = Office.MsoTriState.msoTrue pp.WindowState = PowerPoint.PpWindowState.ppWindowMinimized Application.DoEvents()
5
6582
by: mabond | last post by:
Hi recently read a posting and reply about Excel processs still running after the Appliction.Quit was called. Thought I might be able to use the same (System.Runtime.InteropServices.Marshal.ReleaseComObject(exApplication)) to solve my problem but could not. Background : My app uses a WebBrowser control to display to the user the contents of an Excel spreadsheet.:
0
2758
by: liam_jones | last post by:
I'm very new to Python, well IronPython to precise, and have been having problems when using Excel. The problem I'm having is the closing of my Excel object. I'm able to successfully quit the Excel Application that I create, but when I open a Workbook in the Application I can't successfully Quit Excel (by this I mean I can quit it, but the Excel process isn't getting killed and I have to manually go this through Task Manager). I've...
4
4279
by: Henry Stockbridge | last post by:
Hi, I am using Access 2003 to automate an Excel workbook, but after the code completes Excel does not quit (at least it is still listed in Task Manager --Processes.) I have set a reference to the Excel 11.0 object library. I have declared my Excel variables as... Dim appExcel
3
8117
by: WPeterson | last post by:
Converting PowerPoint to Flash would absolutely be a good choice to distribute your bulky PowerPoint presentations. You can do the whole PowerPoint to Flash conversion manually or with professional applications. First, you'll need to prepare the PowerPoint files. Make sure you are not using any complicated gradients or animations. These will be interpreted poorly when they are brought into Flash. Also, make sure there are no objects that...
2
6424
by: LucasLondon | last post by:
Hi, I'm trying to use VBA to extract underlying data from charts in powerpoint to excel, i.e from the underlying powerpoint datasheet that feeds the chart. I've found the macro below on the net. It copies the data in each chart/datasheet and slide in powerpoint but I'm struggling with the bit to get the data into excel. Below it I've tried incoporating some code to paste into excel but it does not seem to work. Hope someone can...
1
11903
by: chrizstone | last post by:
Hi Guys, What i want to do is: I want to create a Slide programmatically where a Table is on it! Here´s my Code: String strTemplate; strTemplate = template; String tableSlide = @"C:\Temp\TableSlide_" + guid.ToString();
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9911
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8934
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...
0
6713
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();...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
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
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2850
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.