Close Excel

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I try the following module to close the Excel, but it didn't work. I am using
a simplified Chinses version, does it make any difference? It is a module I
found in here.

Public Function CloseMyExcel()
Excel.Application.Quit
End Function
 
It depends upon how you opened EXCEL in the first place. Please provide more
details about what you're doing.
 
There are few situiations.
1 Opened by the Macro, runapp, in Access.
2 Opened by activited the application.
3 Run the module but EXCEL is not opened.

One more question, can this module apply to a macro in EXCEL? I want to
build a Macro to close EXCEL in EXCEL.

Thanks for your reply.
 
The function that you're trying to use will not work unless your database
file has a reference set to the specific EXCEL library. And even then, I
don't believe it will work unless you have opened EXCEL via VBA code
(Automation), where you have created the object in the code.

My own quick testing shows that it won't work if you open EXCEL via RunApp
macro action, and then try to run this function (even if you set the EXCEL
library to be part of the database's references). Nor does it work if you
open EXCEL yourself (outside the database).

If you run the function and EXCEL is not open, nothing will happen (no
errors, etc.).

It's possible to have an EXCEL macro close the EXCEL application. And it's
possible for that EXCEL macro to be run from ACCESS, but only via VBA code
(not by a macro).
--

Ken Snell
<MS ACCESS MVP>
 
It's essentially the same as what you posted:

Public Sub CloseExcel()
' This macro is for EXCEL, not for ACCESS
Application.Quit
End Sub
 
Back
Top