473,386 Members | 1,795 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,386 software developers and data experts.

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.Application has a Quit event in its parent
interface ApplicationEvents4_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 3184
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.com

<hs****@gmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.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.Application has a Quit event in its parent
interface ApplicationEvents4_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.Application
instance, including using the Marshal.ReleaseComObject().
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.Application, 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:
ReleaseComObject(): good for WaitForExit(), bad for BeforeSave
no ReleaseComObject(): 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
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...
6
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#...
8
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 =...
5
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...
0
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...
4
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...
3
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...
2
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...
1
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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,...

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.