Excel won't Close

  • Thread starter Thread starter Guest
  • Start date Start date
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.
 
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.
 
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.
 
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.
 
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 ...
 
Back
Top