kim_wei
asked on
shut down excel
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
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
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
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
xlApp3.Quit