Completely unloading excel from vb6. Is there an answer?

H

Hcoms

Hello,

I know this question has been asked a number of times and i have looked
through google for an answer. However i still have not found an answer to
how to completely unload Excel from vb6 without ctl+alt+delete.
i use the standard code to open an excel doc using late binding
Dim xlapp As Object

Set xlapp = CreateObject("Excel.Application")
xlapp.Visible = True

Dim iNew As Integer
Dim iOld As Integer


Dim wb As Workbook
Dim ws As Worksheet

And to close i use this:
xlapp.ActiveWorkbook.Close False




xlapp.Quit
xlapp.UserControl = False

Set ws = Nothing
Set wb = Nothing
Set xlapp = Nothing

Excel still is in the task manager and if you attempt to run the code again
before closing the vb project it will crash each time!! Please Help!!!
 
B

Bob Phillips

Try not closing the file.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
D

Dave Peterson

I don't use vb, do you use any other excel object variables (ranges???) that
need to be reset to nothing?
 
I

Ivan F Moala

What other code have you got in your routine?

for instance,
Set oWS = oExcel.ActiveSheet

Range("A1").Value = 25
Application.DisplayAlerts = False
Workbooks("Book1").Close

should be

Set oWS = oExcel.ActiveSheet

oWS.Range("A1").Value = 25
oExcel.DisplayAlerts = False
oExcel.Workbooks("Book1").Close

If you do not Explicitly refence the Excel object you will get
Excel will remain referenced even though you close & quit.
 
N

NickHK

Hcoms,
You say you are using late binding. Then you can't have the references to
"Workbook" & "Worksheet" as you need a reference the Excel library.

For me the above code allows Excel to unload, so the problem is in some of
the code that you have not shown here.

Also .UserControl is read only.

NickHK
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top