close excel; leave access open

D

Domenick

Here is the end part of my code (lots of other stuff done first) where I want
to open a database in Access (so that the user can take further action) and
then close out excel:

Set mdapp = CreateObject("access.application")
With mdapp
..Visible = True
..OpenCurrentDatabase ("S:\Financial Analysis\Labor Report.mdb")
End With
Windows("labor report.xls").Activate
ActiveWorkbook.Save
ActiveWorkbook.Close
Excel.Application.Quit

However, this closes out the MS Application as well as the Excel
Application. Note: This only started happening when I switched to Excel 2007
from 2003 (in 2003, excel would close but access would stay open). Anyone
know what could have changed? How should I re-write to get the desired result?

Thanks.
 
B

Barb Reinhardt

I'm not sure I'd put it here, but here's some code to try

Dim xlApp as excel.application
ActiveWorkbook.Save
Set xlApp = Application
ActiveWorkbook.Close

'i suspect you're running this code in excel.
'When you do this, execution of your excel code ends
xlApp.Quit

If you run the code out of another application, it should quit excel and
keep the other application open.
 

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