Solved

Close Excel Application Using VBA.

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
allStar challenge 1 52
strCopies  challenge 17 82
create an incrementing variable name AutoHotKey 5 77
move one pixel 4 58
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This is about my first experience with programming Arduino.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

910 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

22 Experts available now in Live!

Get 1:1 Help Now