Solved

Close Excel Application Using VBA.

Posted on 2004-04-20
5
2,036 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This is an explanation of a simple data model to help parse a JSON feed
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
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…

752 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