Solved

shut down excel

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

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

832 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