Excel Process

K

Kenneth Hutson

I wrote this code in VB2005 Express Beta. When the Sub ends, Excel still
shows as a running process in the Task Manager. How do I shut Excel down?

Thanks,

Kenneth Hutson

San Antonio, TX

Code:
Imports Microsoft.Office.Interop

Module DataSet2Excel

Sub startxl()

Dim xlapp As Excel.Application

Dim wb As Excel.Workbook

Dim ws As Excel.Worksheet

Dim r As Excel.Range

xlapp = New Excel.Application

xlapp.Visible = True

wb = xlapp.Workbooks.Add

ws = CType(wb.Worksheets.Add, Excel.Worksheet)

xlapp.Workbooks.Close()

xlapp.Quit()

End Sub
 
C

Chuck

Try

xlapp.Application.Quit()

Also

xlapp = nothing
or
set xlapp = nothing (not familiary with VB2005 but in VBA you'd set the
xlapp object with
set xlapp = New Excel.Application
and you'd destroy it with
set xlapp = nothing

You may also need to destroy your ws object.
 
P

Perry

I'm wondering how the Quit() method is part of the Excel.Application
namespace.
Did you get this line through the JIT compiler ?

Try to instantiate the Excel object using :
Dim xlapp As New Excel._ApplicationClass()

You can also try to Dispose() the "xlapp" object or force the GC (garbage
collector) to collect.

Krgrds,
Perry
 

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