Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Closing workbooks w/o closing Excel | Excel Discussion (Misc queries) | |||
Closing Excel | Excel Discussion (Misc queries) | |||
Closing VB triggers closing Excel | Excel Programming | |||
closing excel after closing a workbook | Excel Programming | |||
Closing Excel | Excel Programming |