|
-
Jun 29th, 2006, 08:38 PM
#1
Thread Starter
Junior Member
Search not helping with Orphaned Excel in task Mngr
Hi Folks,
I have spent much of the afternoon searching the forum and thinking I had solved my issue with Excel processes not terminating when referenced from my VB6 application. I have not.
While I understand the concepts laid out in si_the_geek's thread on Excel here (http://vbforums.com/showthread.php?t=391665) as well as eer3's answers at http://vbforums.com/showthread.php?t=68080, I still get the problem when I bring a workbook into the mix.
Here is a project created from scratch, referencing Excel as outlined in si's post:
VB Code:
Dim oXLApp As Excel.Application 'Declare the object variables
Dim oXLBook As Excel.Workbook
Dim oXLSheet As Excel.Worksheet
Private Sub Command1_Click()
Set oXLApp = New Excel.Application 'Create a new instance of Excel
Set oXLBook = oXLApp.Workbooks.Add 'Add a new workbook
Set oXLSheet = oXLBook.Worksheets(1) 'Work with the first worksheet
End Sub
Private Sub Command2_Click()
Set oXLSheet = Nothing 'disconnect from the Worksheet
oXLBook.Close SaveChanges:=False 'Close (and disconnect from) the Workbook
Set oXLBook = Nothing
oXLApp.Quit 'Close (and disconnect from) Excel
Set oXLApp = Nothing
End Sub
This is a literal cut and paste of the thread, yet after clicking Command2, Excel.exe remains in the task manager. After re-reading si's thread and the one eer3 posted to, I created another new project, this time without referencing Excel in VB6:
VB Code:
Dim oXLApp As Object
Dim oXLBook As Object
Private Sub Command1_Click()
Set oXLApp = CreateObject("Excel.Application")
oXLApp.Visible = True
End Sub
Private Sub Command2_Click()
oXLApp.Visible = False
oXLApp.quit
Set oXLApp = Nothing
End Sub
Private Sub Command3_Click()
Set oXLBook = oXLApp.workbooks.Add
End Sub
Private Sub Command4_Click()
oXLBook.Close
Set oXLBook = Nothing
End Sub
In this case, I broke out the creation of the application and the addition of the workbook. Running command 1 and 2 had the desired results. Excel disappeared from the task manager. However, as soon as command 3 and 4 were brought in to the mix (i.e. 1_Create Excel 3_add a workbook 4_ close the workbook 2_close Excel), the problem re-occurred. Obviously the problem is when I bring the work book into the equation (which is confirmed by commenting out workbook and worksheet references n the first code example).
So what am I doing wrong here? These are cut and pastes out of threads where others are claiming their problems were solved. Are these solutions out dated? I run XP home SP2 with VB6 and Office XP (Excel 10). Thanks for any help
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|