CreateObject instance not closing

UALynn

New Member
Joined
Mar 22, 2004
Messages
15
Ran into something odd, wondering if anyone out there has seen it or knows a fix.

Used the createobject method to create an Excel instance in a VBA module form MS Access. When I used the .quit for the object the excel instance stayed 'out there'

I found that in the process list the excel instance created through my code was listed as 'excel' while an instance created from opening excel regularly listed as 'Microsoft Excel'.

Why are they different?
Is it due to the OS being win 98?
How do I get around it in a way that will continue to work if the OS changes?

Also posted on the UA forum
http://www.utteraccess.com/forums/showthreaded.php?&Number=420764
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Hi,

I can't replicate your problem here right now. However, I've heard that one method is to set the UserControl property of Excel to true before quitting e.g.

Code:
    Dim xlApp As Object

    Set xlApp = CreateObject("Excel.Application")

    'Do some stuff here


    xlApp.UserControl = True
    xlApp.Quit

If you can't get that to work then can you post an example of where this is happening - the smaller the example the better :)

HTH
Dan
 
Upvote 0
Solution

Thanks All!
Would you believe the solution was
Code:
Set myXlObj = Nothing: Set mySht= Nothing
needed to be reversed to
Code:
Set mySht = Nothing: Set myXlObj = Nothing
:oops:
 
Upvote 0
Well, for whatever is worth, I always try to set the objects to nothing in a "parental" basis... something like

Code:
Dim xlApp As Object
Dim xlBook As Object
Dim xlSheet As Object
Dim xlRng As Object

'code here...

'remove references
Set xlRng = Nothing
Set xlSheet = Nothing
Set xlBook = Nothing
Set xlApp = Nothing
 
Upvote 0
It's worth a lot Juan, as that was the problem. ;)

This whole block is an issue, the workbook's out of order as well:

Set myBk = Nothing
Set rsS = Nothing: Set db = Nothing
Set myXlObj = Nothing: Set mySht = Nothing

Should be:

Set mySht = Nothing: Set myBk = Nothing
Set myXlObj = Nothing
Set rsS = Nothing: Set db = Nothing

The DB objects were in correct order. :)
 
Upvote 0

Forum statistics

Threads
1,215,391
Messages
6,124,673
Members
449,178
Latest member
Emilou

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top