Solved

shut down excel

Posted on 2004-08-05
4
132 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Suggested Solutions

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

860 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