Solved

Closing Excel from Access app!!

Posted on 2002-07-13
3
297 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 52

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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

687 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