LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to kill excel from visual basic

Hi
I am using the followig code. The thing is that excel won't stop. It is
something related to For...Next.
If I remove For...Next then everything is ok. What could be wrong?


On Error GoTo ErrorHandler

Dim MyXLApp As New Excel.Application
Application.DisplayAlerts = False
Dim strSheetName As String
strSheetName = "INFORMATION"
MyXLApp.Workbooks.Open FileName:="C:\yyy\1_08A.xls"



If MyXLApp.Worksheets.Count = 1 Then
MyXLApp.Worksheets.Add.Name = "DELETE"
MyXLApp.Workbooks.Application.SaveWorkspace
End If

If MyXLApp.Worksheets.Count 1 Then
For buc_sheets = 1 To MyXLApp.Worksheets.Count
den_sheet = Worksheets(buc_sheets).Name
If strSheetName = den_sheet Then
MyXLApp.Worksheets(den_sheet) Then
MyXLApp.Worksheets(strSheetName).Activate
MyXLApp.Worksheets(strSheetName).Delete
End If
Next
End If
GoTo line100
MyXLApp.Workbooks.Application.SaveWorkspace
line100:
MyXLApp.Workbooks.Application.SaveWorkspace
MyXLApp.Workbooks.Close
Application.DisplayAlerts = True
MyXLApp.Application.Quit
Set MyXLApp = Nothing
ErrorHandler:
Select Case Err.Number
Case 9
MsgBox Err.Description
End Select

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is Visual Basic the same as Visual Studio 2008? Mike Stewart Excel Worksheet Functions 5 January 11th 09 04:58 PM
Can I run Visual Basic procedure using Excel Visual Basic editor? john.jacobs71[_2_] Excel Programming 3 December 26th 05 02:22 PM
changing the visual basic in office 2003 to visual studio net bigdaddy3 Excel Discussion (Misc queries) 1 September 13th 05 10:57 AM
Excel/Visual Basic MikeS[_2_] Excel Programming 3 October 12th 04 05:44 PM
Visual Basic within Excel visually challenged Excel Programming 3 June 11th 04 11:21 PM


All times are GMT +1. The time now is 06:08 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"