Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Closing Excel from a DLL

I've written a VB6 dll that creates an instance of the
Excel.Application object, however I can't seem to close the process
once I've finished with it.

Although I call Quit() and set my object variable to Nothing I can
still see the Excel.exe process running in Task Manager.

Is there someway I can force this process to end?

Thanks in advance

Craig
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Closing Excel from a DLL

Craig,

Have you made sure that all workbooks are closed before quitting?

--

HTH

RP
(remove nothere from the email address if mailing direct)


"CraigB" wrote in message
om...
I've written a VB6 dll that creates an instance of the
Excel.Application object, however I can't seem to close the process
once I've finished with it.

Although I call Quit() and set my object variable to Nothing I can
still see the Excel.exe process running in Task Manager.

Is there someway I can force this process to end?

Thanks in advance

Craig



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Closing Excel from a DLL

The Count property on the WorkBooks collection is 0 just before I call
Quit and I explicitly close my workbook before calling quit.
btw I'm using Office 2003.

Craig

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Closing Excel from a DLL

Craig,

Another thought is that you should maybe try releasing all the object
variables after the quit (you know, Set xlApp = Nothing etc.). Try all of
them.

If this fails, try this hint posted by Jake Marx a while back

....
However, when automating Excel (and when Excel is not visible), problematic
code will run, and you may not be notified of an error that has occurred.
When this happens, the .Quit and Set = Nothing commands seem to release the
reference VB has to Excel, but the Excel application stays open in a limbo
state. The best way to debug this type of situation is to set the Visible
property of the Excel.Application object to True at the beginning of your
code and step through it. Any runtime errors should be raised in the Debug
environment when you do it this way. Once you get the code working
correctly, then you can get rid of the Visible statement.
,,,

If this is not the problem, try reducing your code to the bare bones that
fails to work, post it, and I will try to re-create.


--

HTH

RP
(remove nothere from the email address if mailing direct)


wrote in message
ups.com...
The Count property on the WorkBooks collection is 0 just before I call
Quit and I explicitly close my workbook before calling quit.
btw I'm using Office 2003.

Craig



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Closing Excel from a DLL

Bob,

I thought it might have been my object variable too as I get references
to sheets and the workbook but explicitly setting them to Nothing first
didn't help.
I've been playing with it a bit more and seem to have it narrowed down
to something to do with the SaveAs method.

Dim xls As Excel.Application
If xls Is Nothing Then Set xls = CreateObject("Excel.Application")
'xls.DisplayAlerts = False

Dim wkbk As Workbook, sheet As Worksheet
Set wkbk = xls.Workbooks.Add
Set sheet = wkbk.ActiveSheet

wkbk.SaveAs "c:\temp.xls"
wkbk.Close SaveChanges:=False

Set sheet = Nothing
Set wkbk = Nothing

xls.Quit
Set xls = Nothing

If I comment out the SaveAs line then the Excel process does end but
with it in, it hangs around.

Cheers

Craig



  #6   Report Post  
Posted to microsoft.public.excel.programming
Rex Rex is offline
external usenet poster
 
Posts: 26
Default Closing Excel from a DLL

Maybe this has something to do with touching the file system. I have an
equally simple example which also leaves Excel running:
Dim XL As Excel.Application
Dim WB As Excel.Workbook
Set XL = CreateObject("Excel.Application")
XL.Visible = True
Set WB = XL.Workbooks.Open("C:\temp\Anyold.xls")
WB.Close False
Set WB = Nothing
XL.Quit
Set XL = Nothing

I can "fix" it by taking out the .Open and .Close. I posted this in
November and the only suggestion was to go back and kill off the Excel
processes when I was done with them.

" wrote:

Bob,

I thought it might have been my object variable too as I get references
to sheets and the workbook but explicitly setting them to Nothing first
didn't help.
I've been playing with it a bit more and seem to have it narrowed down
to something to do with the SaveAs method.

Dim xls As Excel.Application
If xls Is Nothing Then Set xls = CreateObject("Excel.Application")
'xls.DisplayAlerts = False

Dim wkbk As Workbook, sheet As Worksheet
Set wkbk = xls.Workbooks.Add
Set sheet = wkbk.ActiveSheet

wkbk.SaveAs "c:\temp.xls"
wkbk.Close SaveChanges:=False

Set sheet = Nothing
Set wkbk = Nothing

xls.Quit
Set xls = Nothing

If I comment out the SaveAs line then the Excel process does end but
with it in, it hangs around.

Cheers

Craig


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
Closing workbooks w/o closing Excel Barb in MD Excel Discussion (Misc queries) 3 February 15th 10 06:42 PM
Closing Excel chip1in Excel Discussion (Misc queries) 2 August 31st 09 04:49 PM
Closing VB triggers closing Excel Minilek Excel Programming 2 August 6th 04 05:17 PM
closing excel after closing a workbook CWalsh[_2_] Excel Programming 3 January 21st 04 03:33 PM
Closing Excel Phil Excel Programming 2 October 29th 03 09:43 PM


All times are GMT +1. The time now is 03:15 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"