Solved

Close Excel Application Using VBA.

Posted on 2004-04-20
5
2,037 Views
Last Modified: 2008-02-01
Hi
I am trying to write data into  Excel workbook from Access database. Data extraction and formating part is ok. I am not able to close the Excel application after the writing the data. The code written to close the application as follows.

objExcelApp.Workbooks(1).Close
objExcelApp.Quit
Set objexcelWrksheet = Nothing
Set objExcelworkbook = Nothing
Set objExcelApp = Nothing

Even after closing the Excel application Task Manager "Process Tab" shows the Excel process is running. Is there any way to close Excel aapplication completely.

Help!!!!!!!!!!!!!!!!!!


Regards
Citims.

0
Comment
Question by:citims
[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
5 Comments
 
LVL 1

Expert Comment

by:VosJ
ID: 10867556
Each time that you open Excel (from within VBA or Excel.exe) you get a new process started. With the quit command you only terminate 1 excelprocess (the one opened with objexcelapp).
So are you sure that there are no other versions of Excel running?
0
 

Author Comment

by:citims
ID: 10867637
Hi

No other Excel files are opened. I am trying to debug this isuue, so no other applications are opened.


Regards
Citims
0
 
LVL 1

Accepted Solution

by:
dapcom earned 30 total points
ID: 10867673
It should close when the last reference to it is set to Nothing (Your Set objExcelApp = Nothing)

Check if you have another variable that reference the application object (or any other object I guess, ie workbooks...) that is not set to nothing.

Daniel
0
 
LVL 19

Expert Comment

by:Melih SARICA
ID: 10867827
Post codes between creating and closing events...

There is something within this part... The code u ve send above is true .. nothing wrong with it ..

0
 
LVL 65

Expert Comment

by:rockiroads
ID: 10867853

maybe you need to add the Close events on the worksheets and workbook
eg
objExcelworkbook.Close
objExcelworkbook.Quit

so you would have


objExcelApp.Workbooks(1).Close
objExcelApp.Quit
Set objExcelApp = Nothing

Set objexcelWrksheet = Nothing  'Unsure if close required on worksheet

objExcelworkbook.Close
objExcelworkbook.Quit
Set objExcelworkbook = Nothing

0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

622 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