473,320 Members | 2,035 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,320 software developers and data experts.

Close Excel and Detecting Excel Close counterintuitive...

I'm trying to automate some very simple things in excel, but have run into a roadblock (using c++). To detect excel closing, I just monitor the Excel Process using WaitForSingleObject. In order to close it myself, I just call ExcelApp.Quit(). Really basic stuff. Only problem is - I need to release all dispatches to detect the Excel process closing, but I need those dispatches (at least the application one) in order to close excel myself. Am I missing something? It seems like I can have only one or the other. Also, I am opening multiple instances of Excel, so I can't just use GetActiveObject. Is there something I'm missing or some piece of vital information I need? Maybe I'm completely ignorant towards the way this all works and don't realize it? How can I detect the process closing (or any method to detect excel is exiting) as well as always having a way to interface with that instance of excel? Thanks

Cheers
-Scott
Sep 25 '07 #1
1 2716
Im a bit rusty when it comes to COM programming, but you can take advantage of COM Events so a COM application can let you know when things happen.

Excel has a "BeforeClose" event in the Application object, you might want to take a look into it, hopefully it is what you need.

As far as I remember you need to implement IConnectionPoint inside a C++ class to be able to subscribe to a COM event.
Sep 25 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

14
by: IanW | last post by:
I don't know if this is in the right place but.. I am writing a VB.Net Class Library which uses Excel to produce workbooks If I create an instance of Excel and then close it I can get .NET to...
2
by: Lorenzo Melato | last post by:
Hi everyone, I have a very strange problem. If I open a .NET application from EXCEL using SHELL function, when I close EXCEL, the EXCEL.EXE process remain active and I must close it by Task...
5
by: Richie | last post by:
I want to close excel application from C#, this is the piece of code I am trying "System.Runtime.InteropServices.Marshal.ReleaseComObject(excelApp);" GC.Collect(); It ain't working ! Any ideas...
1
by: Gary Cobden | last post by:
Hi I have a routine that uses VBA to open a hidden occurence of Excel, and do background computations. However, in the event that the routine terminates abnormally, I have not been able to...
3
by: David Berman | last post by:
Hi, I've written an application to do a while bunch of Excel automation. I open a file, scan through all the worksheets, extract data, and then I try to close Excel. However, I can see that I'm...
5
by: Wenke Ji | last post by:
Hi I open a Excel workbook using below API: Set ExcelServer = CreateObject("EXCEL.Application") Set TargetWorkbook = ExcelServer.Workbooks.Open (CurrentBook) Befor the programm exit , I use...
1
by: Fred Morrison | last post by:
In VB6, I would check to see if Excel was already running by this technique Private m_booExcelCreatedHere As Boolean Dim xlApp as Excel.Application On Error Resume Next ' temporarily...
3
by: Michael Kellogg | last post by:
My application works with Excel to put together spreadsheets for reporting purposes. It runs just fine on my box, but when I put it on another one, it bombs. Here is the relevant code: ...
10
by: Hendri Adriaens | last post by:
Hi, I'm trying to automate the creation of an excel file via COM. I copied my code below. I read many articles about how to release the COM objects that I create. The code below runs just fine...
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
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: 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: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.