Closing an opened Excel file, Code?

M

Matt

I am trying to close an Excel file using the code below. The code is used
for a form in a form load and closed when an Exit cmd button is clicked. The
form uses a subform which contains data from an Access table. The data in
this Access table was imported and linked to the open Excel file. Now, my
code will close Excel when the subform is not included, however when it is
Excel remains open after the Exit button is clicked. Why is it anytime I use
the linked Access Table, Excel will not close using the code below?

Thanks,
Matt

Private xls As Excel.Application
Private wk As Excel.Workbook

Set xls = New Excel.Application
xls.Visible = False

Set wk = xls.Workbooks.Open("c:Excel.xls", True)

wk.Close False
xls.Quit

Set wk = Nothing
Set xls = Nothing
 
Top