Solved

Closing Excel from Access app!!

Posted on 2002-07-13
3
293 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 49

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
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…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

914 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now