Solved

Closing Excel from Access app!!

Posted on 2002-07-13
3
295 Views
Last Modified: 2008-03-10
I am linking to an Excel workbook from my access application using VBA.  Below is the code I use to both link to, and close the Excel workbook.  But, a new instance of Excel still runs in the background for everytime I run the import.  Help!

Set xlApp = CreateObject("Excel.Application")
Set dOpen = xlApp.Dialogs(xlDialogActivate)
bOpen = xlApp.Dialogs(xlDialogOpen).Show

...
...
...

xlApp.Quit
Set xlApp = Nothing
 
0
Comment
Question by:krolfes
3 Comments
 
LVL 51

Accepted Solution

by:
Ryan Chong earned 100 total points
ID: 7152039
TRy this instead:

On Error Resume Next
Set xlApp = GetObject(,"Excel.Application")
On Error Goto ErrorHandler
If xlApp Is Nothing Then Set xlApp = CreateObject("Excel.Application")
Set dOpen = xlApp.Dialogs(xlDialogActivate)
bOpen = xlApp.Dialogs(xlDialogOpen).Show

...
...
...

xlApp.Quit
Set xlApp = Nothing

We use the GetObject function to get if an instance of Excel Application is loaded in memory or not.

cheers
0
 
LVL 54

Expert Comment

by:nico5038
ID: 7281396

No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
 - Answered by: ryancys  
Please leave any comments here within the
next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

Nic;o)
0
 

Expert Comment

by:ComTech
ID: 7315333
As per recommendation, I hace accepted ryancys comment.

Thanks,
ComTech
CS Amdin @ EE
0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question