Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Close Excel Application Using VBA.

Posted on 2004-04-20
5
Medium Priority
?
2,038 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 90 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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them.

Question has a verified solution.

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

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…
If you are a mobile app developer and especially develop hybrid mobile apps then these 4 mistakes you must avoid for hybrid app development to be the more genuine app developer.
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…
Progress

730 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