Solved

shut down excel

Posted on 2004-08-05
4
128 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
Comment Utility
try
 xlApp3.Quit
0
 
LVL 11

Expert Comment

by:ajaikumarr
Comment Utility
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
Comment Utility
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
Comment Utility
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

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…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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…
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…

763 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

10 Experts available now in Live!

Get 1:1 Help Now