Solved

shut down excel

Posted on 2004-08-05
4
129 Views
Last Modified: 2010-05-02
hello, all,

  i am using MEXCEL automation to create excel book, sheets in my VB application, it is running fine. At final of this application, a piece of code looking like following is used to close excel , however, when i check "Taskmanager", i can still find "excel.exe" exising there,  what is that, how can i really stop excel? developing environment is Window XP, VB6.0 (SP 5)

'to close excel
...  
xlBook.Close
Set xlApp3 = Nothing
...

thanx in advance
 
0
Comment
Question by:kim_wei
  • 3
4 Comments
 
LVL 5

Expert Comment

by:ZenMasterrr
ID: 11724057
try
 xlApp3.Quit
0
 
LVL 11

Expert Comment

by:ajaikumarr
ID: 11725156
Hai,

Try like this
'Open Excel
Dim oExcel As New Excel.Application
Application.DisplayAlerts = False 'No prompts to overwrite file
oExcel.Visible = True
oExcel.Workbooks.Open FileName:= "C:\myFile.xls"
'Close Excel
oExcel.Close
oExcel.Quit
Set oExcel = Nothing

Bye
Ajai
0
 
LVL 11

Accepted Solution

by:
ajaikumarr earned 50 total points
ID: 11725186
Hai,

Do it like this.
Private Sub Command1_Click()
On Error GoTo ErrorHandler:
    'Open Excel
    Dim oExcel As New Excel.Application
    Application.DisplayAlerts = False 'No prompts to overwrite file
    oExcel.Visible = True
    oExcel.Workbooks.Open FileName:="C:\myFile.xls"
    GoTo ExitExcel

ErrorHandler:
    MsgBox "Error Occuered"

ExitExcel
    'Close Excel
    oExcel.Close
    oExcel.Quit
    Set oExcel = Nothing
End Sub

Bye
Ajai
0
 
LVL 11

Expert Comment

by:ajaikumarr
ID: 11725192
Hai,

Sorry like this...

Private Sub Command1_Click()
On Error GoTo ErrorHandler:
    'Open Excel
    Dim oExcel As New Excel.Application
    Application.DisplayAlerts = False 'No prompts to overwrite file
    oExcel.Visible = True
    oExcel.Workbooks.Open FileName:="C:\myFile.xls"
    GoTo ExitExcel

ErrorHandler:
    MsgBox "Error Occuered"
    GoTo ExitExcel

ExitExcel
    'Close Excel
    oExcel.Close
    oExcel.Quit
    Set oExcel = Nothing
End Sub


Bye
Ajai
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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

863 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

28 Experts available now in Live!

Get 1:1 Help Now