Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Extra reference after opening a file

I am having trouble with an unexplained extra reference to Excel. I'm
hoping someone here can explain.

Here is some pseudo-code that illustrates what my code (that is written in
C) is doing:

IDIspatch * Dispatch
IDIspatch * Workbooks
IDIspatch * File
CoCreateInstance ("Excel.Application,&IDispatch)
Workbooks = PropertyGet(IDispatch,"Workbooks")
File = Invoke(Workbooks,"Open","d:\test.xls")
Workbooks::Release
File::Release
IDispatch::Release

After my program terminates, I see in the XP Task Manager that an instance
of Excel is still running. This does not happen if I skip the Open and
related Release steps.

Can anyone explain why Excel is still running?

Thanks in advance.

David Liebtag



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Extra reference after opening a file

In VB, this is usually because of an unreleased reference. I don't know
anything about C and COM, but I would release in the opposite order that I
created

IDIspatch * Dispatch
IDIspatch * Workbooks
IDIspatch * File
CoCreateInstance ("Excel.Application,&IDispatch)
Workbooks = PropertyGet(IDispatch,"Workbooks")
File = Invoke(Workbooks,"Open","d:\test.xls")
File::Release
Workbooks::Release
IDispatch::Release

I have reversed the release of File and Workbook.

--
Regards,
Tom Ogilvy



"David Liebtag" wrote in message
...
I am having trouble with an unexplained extra reference to Excel. I'm
hoping someone here can explain.

Here is some pseudo-code that illustrates what my code (that is written in
C) is doing:

IDIspatch * Dispatch
IDIspatch * Workbooks
IDIspatch * File
CoCreateInstance ("Excel.Application,&IDispatch)
Workbooks = PropertyGet(IDispatch,"Workbooks")
File = Invoke(Workbooks,"Open","d:\test.xls")
Workbooks::Release
File::Release
IDispatch::Release

After my program terminates, I see in the XP Task Manager that an instance
of Excel is still running. This does not happen if I skip the Open and
related Release steps.

Can anyone explain why Excel is still running?

Thanks in advance.

David Liebtag





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Extra reference after opening a file

Tom,

Thanks, but I had already tried that.

David



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Extra reference after opening a file

I solved the problem. The Open method returns a Workbook object. You have
to call the Workbook's Close method before releasing it.

David Liebtag



Reply
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
CREATION extra FILE WHEN SAVE CC Excel Discussion (Misc queries) 6 August 24th 09 11:42 PM
extra blank file opening Cindy B Excel Discussion (Misc queries) 0 January 7th 09 07:09 PM
Extra/empty records in CSV file Jessica G Excel Discussion (Misc queries) 2 June 21st 06 02:15 AM
How can I avoid circular reference AND extra input maintchief New Users to Excel 3 November 10th 05 12:39 PM
Extra rows in csv file Kevin Excel Programming 1 July 12th 04 01:32 AM


All times are GMT +1. The time now is 03:58 PM.

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

About Us

"It's about Microsoft Excel"