Closing Excel from Access

J

JR_06062005

Access creates a report which is exported to Excel using the
TransferSpreadsheet function. My code then opens the file in Excel workbook,
makes some format changes and then saves and closes the file.

The workbook I created closes, but Excel, with no open workbook, remains
open. I tried to close it with the code Excel.Application.Quite. But this
does not close the application.

How do I close the whole Excel application?
 
J

JR_06062005

I think you are exactly right. The problem is I can't figure out how to
create a quailfied copy. What I'm doing is creating a spreadsheet with the
TransferSpreadsheet function and then bringing up the workbook that the
TransferSpreadsheet function just created, making some changes and then
closing the workbook. What I want to do after I finish the changes, is close
the workbook and if Excel is not running, close down Excel. Problem is I can
only close the workbook, not the program even if Excel was not previously
running. By the way I have code to tell me whether Excel is running.

As I understand the process, when I create a new workbook, if Excel was not
already running, then it is automatically started (which is an unqualified
reference). So how do I make a qualified reference?
 
T

Tom Ogilvy

I assumed you opened the workbook using automation, If the
Transferspreadsheet function opens excel as a byproduct of creating the
sheet, then I couldn't say. If you are using automation, then you should e
creating a reference to excel

oxlApp = GetObject(,"Excel.application")
set oxlBk = oxlApp.workbooks.Open("Mynewbook.xls")

and so forth.
 

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