Excel won't Close

G

Guest

I use the following code to open a workbook and run three macros in an excel
workbook:

Dim ObjExcel As Object 'Excel.Application
Set ObjExcel = New Excel.Application
ObjExcel.Visible = True
AppActivate "Microsoft Excel"
Workbooks.Open strPath & "Protocols-Cleanup.xls"
ObjExcel.Run "Protocols_Filters"
'ObjExcel.Run "Builtin_Filters"
'ObjExcel.Run "Filters_CFGFile"
ObjExcel.Quit
Set ObjExcel = Nothing

Unfortunately, the OS doesn't let go of Excel. Access completes all it
work, but Excel is still active when I look in the Task Manager. How can I
get it to close.

BTW I've tried this on a Windows 2000 and XP PC using Office 2000 or Office
XP. Neither let go of Excel.
 
K

Ken Snell [MVP]

Change this line:
Workbooks.Open strPath & "Protocols-Cleanup.xls"

to this:
ObjExcel.Workbooks.Open strPath & "Protocols-Cleanup.xls"

When you don't use the object you created for EXCEL, VBA creates a new
object to use.
 
G

Guest

That did it. Thank you very much!



Ken Snell said:
Change this line:
Workbooks.Open strPath & "Protocols-Cleanup.xls"

to this:
ObjExcel.Workbooks.Open strPath & "Protocols-Cleanup.xls"

When you don't use the object you created for EXCEL, VBA creates a new
object to use.
 
G

Guest

Hi,
I'm also having problems with Excel not closing, so I tried using your code
here. But Access doesn't like Set ObjExcel = New Excel.Application
It says the user-defined type is not defined. Any suggestions? Thanks.
 
V

Van T. Dinh

Most likely, Microsoft Excel displays a dialog box asking whether you want
to save the changes but you can't see this MsgBox.

Check the Remarks in the Excel VB Help on the Quit Method ...
 

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