V
VanS
Hello,
When running the code below-by clicking a command button whose code deletes
all but the first 3 worksheets in the workbook-I keep getting an error
message"
"This program has performed an illegal operation and will be shut down". So
I ran it in debug to trace the point of error. It occurs after the sheet is
deleted, and the code goes to the worksheet_deactivate routine, performs its
duties and at the point it tries to return to the command button/For ndx code
it bonkers out.
The code works fine under Office XP & 2003 with Win XP, but I am testing
with a Win98 Office 97 testbed under MS Virtual PC-the latter is where the
problem lies. I have checked that the library files are correct for Office
97. Not sure if significant, but the global variable strWorksht under
worksheet_deactivate is populated with the name of the deleted worksheet for
the one working, but empty for the one not working.
Any ideas what could be the problem?
Thanks, God bless
Van
Command button click
For ndx = Workbooks("Quotes.xls").Worksheets.Count To 4 Step -1
' Debug.Print Workbooks("Quotes").Worksheets(ndx).Name
' Debug.Print ndx
' Workbooks("Quotes").Worksheets(ndx).Activate
Workbooks("Quotes.xls").Worksheets(ndx).Delete
Next ndx
' for worksheet being deleted
Private Sub Worksheet_Deactivate()
Dim intYN As Integer
Dim intEndRw As Integer
Dim strFileNum As String
Dim intFileNum As Integer
'Dim strPath As String
booPerform = False
If strWorksht = "" Then Exit Sub
If booQtCreate Then Exit Sub
Application.OnKey "{TAB}" 'fix 08/06/99
Exit Sub
' **************************
If Worksheets(strWorksht).ProtectContents = False Then
Worksheets(strWorksht).Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True ', UserInterface:=True
End If
End Sub
When running the code below-by clicking a command button whose code deletes
all but the first 3 worksheets in the workbook-I keep getting an error
message"
"This program has performed an illegal operation and will be shut down". So
I ran it in debug to trace the point of error. It occurs after the sheet is
deleted, and the code goes to the worksheet_deactivate routine, performs its
duties and at the point it tries to return to the command button/For ndx code
it bonkers out.
The code works fine under Office XP & 2003 with Win XP, but I am testing
with a Win98 Office 97 testbed under MS Virtual PC-the latter is where the
problem lies. I have checked that the library files are correct for Office
97. Not sure if significant, but the global variable strWorksht under
worksheet_deactivate is populated with the name of the deleted worksheet for
the one working, but empty for the one not working.
Any ideas what could be the problem?
Thanks, God bless
Van
Command button click
For ndx = Workbooks("Quotes.xls").Worksheets.Count To 4 Step -1
' Debug.Print Workbooks("Quotes").Worksheets(ndx).Name
' Debug.Print ndx
' Workbooks("Quotes").Worksheets(ndx).Activate
Workbooks("Quotes.xls").Worksheets(ndx).Delete
Next ndx
' for worksheet being deleted
Private Sub Worksheet_Deactivate()
Dim intYN As Integer
Dim intEndRw As Integer
Dim strFileNum As String
Dim intFileNum As Integer
'Dim strPath As String
booPerform = False
If strWorksht = "" Then Exit Sub
If booQtCreate Then Exit Sub
Application.OnKey "{TAB}" 'fix 08/06/99
Exit Sub
' **************************
If Worksheets(strWorksht).ProtectContents = False Then
Worksheets(strWorksht).Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True ', UserInterface:=True
End If
End Sub