Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Close Excel within Access VBA

Status
Not open for further replies.

MacroAlan

Programmer
Dec 4, 2006
134
US
I am already using a snippet I found here to open my Excel spreadsheet:
Code:
Sub CISOpenDataSource(ProcName)
    Dim cmdlgOpenFile As New clsCommonDialog
    Dim FilePather As String
    
    Dim xlApplic As Excel.Application
    Dim wk As Excel.Workbook
    Dim ws As Excel.Worksheet
   [red]'If fatal error, try Reference to Excel ##.0 Object Library[/red]
    Set xlApplic = New Excel.Application

After several processes mess with the Excel (open, switch tabs, save data); I want my Close form event to also close out of Excel. Sometimes it is not visible on the screen but still shows up in the task manager (right now the 2 last instances are consuming 55 MG of resources).

I need Excel to completely shut down. Is this possible? Somebody have some code for me?

Alan
It is easier to apologize than ask permission.

 
You can make the application visible and you can quit. It is also a good idea to destroy the object.

Code:
xlApplic.Visible = True
xlApplic.Quit
Set xlApplic = Nothing
Is this what you mean?
 
Did I make it clear that I need to quit Excel in a different Sub than the one it was opened in?

It is apparently closing the spreadsheet now but not the application.

Alan
It is easier to apologize than ask permission.

 
I need to quit Excel in a different Sub
A common way is to play with global (Public) objects ...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top