LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.sdk,microsoft.public.excel.programming,comp.os.ms-windows.programmer.win32
external usenet poster
 
Posts: 7
Default Should an automated version of Excel close?

I'm writing an application in C++ which will read a couple of
complicated text files and create an Excel worksheet containing data
extracted from these files.

In the process of testing, I got to the point where the program:
- used CoCreateInstance() to create an instance of Excel and obtain
an IUnknown interface
- used QueryInterface() to obtain an IDispatch interface
- used Invoke() to set the Visible property to TRUE

At this point I can see an instance of Excel with no workbook visible on
the computer.

If I let this test version of the program go ahead and call Release() on
each of the interfaces which it has obtained, the instance of Excel
closes. This I take to be normal behavior of an automated application.

After adding code to get an IDispatch interface to the Workbooks object
and calling its Add method, the instance of Excel has a workbook
containing three worksheets, just as if it had been started by clicking
the Excel button.

Now, however if the program proceeds to call Release() on each of the
interfaces, Excel does not close. I have to manually close it by
clicking its close button.

Is this normal behavior? I'm concerned that I may have failed to release
an interface although I can't see what that interface might be. I know
that I have a IUnknown and IDispatch interfaces to the original Excel
object, an IDispatch interface to the Workbooks member, and an IDispatch
interface to the Workbook returned by the Add method. The program calls
Release() for each of these.

Is there anything else I should look for?
--
Norm

To reply, change domain to an adult feline.

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I save an Excel 97-2003 version or 2007 version for Mac 200 Bronigal Excel Discussion (Misc queries) 1 December 7th 09 08:04 AM
Macro - Save an Open Excel Version 4 as current version of Excel planomax Excel Programming 1 February 6th 07 09:41 PM
Close Second Version of Excel file Sparkybird Excel Discussion (Misc queries) 1 July 24th 06 10:54 PM
downloaded version excel 2007 will not close normally when shut do Greg Excel Programming 1 May 30th 06 09:56 AM
Recover earlier version of excel sheet after new version saved? stephanie38 Excel Discussion (Misc queries) 3 June 17th 05 03:52 AM


All times are GMT +1. The time now is 08:44 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"