Solved

Close Excel Application Using VBA.

Posted on 2004-04-20
5
2,031 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
5 Comments
 
LVL 1

Expert Comment

by:VosJ
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
withoutTen challenge 14 87
Order table with macro 3 74
factorial example challenge 10 60
word0 challenge 4 52
Purpose To explain how to place a textual stamp on a PDF document.  This is commonly referred to as an annotation, or possibly a watermark, but a watermark is generally different in that it is somewhat translucent.  Watermark’s may be text or graph…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
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…

762 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

8 Experts available now in Live!

Get 1:1 Help Now