Solved

Closing Excel from Access app!!

Posted on 2002-07-13
3
290 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
Comment Utility
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
Comment Utility

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
Comment Utility
As per recommendation, I hace accepted ryancys comment.

Thanks,
ComTech
CS Amdin @ EE
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

771 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

12 Experts available now in Live!

Get 1:1 Help Now