Corrupt Excel Workbook

I have a workbook containing 2 userforms and 2 modules of VBA code (Excel97).  It now crashes Excel when I go into the Visual Basic Editor and I can't get to my code..  but it does run the forms and the code via an AutoOpen macro..  I have tried Excel Recovery version 1 but it only recovers the AutoOpen macro....  

Help...  Delboy
DelboyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

awdCommented:
Try holding down the shift key when you open the workbook.  This should prevent the macro from running.  That way you ahould be able to get into the workbook and fix the problem.
0
DelboyAuthor Commented:
This only stops the AutoOpen macro, but still cannot get into the visual basic editor without crashing once in the workbook...
0
awdCommented:
I see. I misunderstood your problem. I will give it some more thought.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

DelboyAuthor Commented:
I look forward to it..  D.
0
shalbeCommented:
Delboy,

If you will send the file to me, I'll take a look at it and see if I can get to your code. You can send the file to shalbe@san.rr.com

Steve
0
awdCommented:
Delboy,

What happens when it crashes?
0
DelboyAuthor Commented:
It crashes Excel altogether...
0
frazerCommented:
Hi,

Could you send the file to me as well please.  I think I can get at the code only using a handle.

frazer@flying-worm.demon.co.uk

regards

Frazer
0
awdCommented:
Have you tried copying the workbook to a new file to see if the problem persists?  What if you try getting at the code through the Tools-Macro-Macros menu option?  Do you get the same behavior?  Can you delete macros from this spot?  Can you access the code editor in other workbooks?
0
DelboyAuthor Commented:
Everything you have just said, I have done to no avail...nice try though awd...  copying to a new workbook brings the problem with it, going through the Tools etc option has the same results, cannot delete macros .. and can go into the editor in other workbooks..  

D
0
shalbeCommented:
Delboy,

I got into the Visual Basic Editor in your file. I commented out the lines in the Auot_Open macro and resaved itt. it works fine now. It probably had something to do with you turning off screen updating and then trying to show a dialog box ???

Anyway, I got into it by recording a new macro and then editing that. This opened the Visual Basic Editor and I could get at your macro.

I am sending the file to you via email.

Steve
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
frazerCommented:
Hi,

alternativly,

here is your code....


'Module1


Sub Auto_Open()
    ScreenUpdating = False
    UserForm2.Show
End Sub



'UserForm1


Private Sub CommandButton1_Click()
    If UserForm1.TextBox2.Value = """" Then
    MsgBox ""Please Fill In The Name Field"", vbExclamation, ""Name""
        UserForm1.TextBox2.SetFocus
        Exit Sub
    End If
    If UserForm1.TextBox4.Value = """" Then
    MsgBox ""Please Fill In The Project Field"", vbExclamation, ""Project""
        UserForm1.TextBox4.SetFocus
        Exit Sub
    End If
    If UserForm1.TextBox1.Value = """" Then
    MsgBox ""Please Fill In The Date Field"", vbExclamation, ""Date""
        UserForm1.TextBox1.SetFocus
        Exit Sub
    End If
    If UserForm1.TextBox8.Value = """" Then
    MsgBox ""Please Fill In The Start Date Field"", vbExclamation, ""Start Date""
        UserForm1.TextBox8.SetFocus
        Exit Sub
    End If
    If Label25.Visible = True Then
        MsgBox ""Please Enter A Valid Start Date In The Start Date Field"", vbExclamation, ""Start Date""
        UserForm1.TextBox8.SetFocus
        Exit Sub
    End If
    If UserForm1.TextBox5.Value = """" Then
    MsgBox ""Please Fill In The Team Leader Field"", vbExclamation, ""Team Leader""
        UserForm1.TextBox5.SetFocus
        Exit Sub
    End If
    If UserForm1.TextBox6.Value = """" Then
    MsgBox ""Please Fill In The Supervisor Field"", vbExclamation, ""Supervisor""
        UserForm1.TextBox6.SetFocus
        Exit Sub
    End If
    If UserForm1.TextBox7.Value = """" Then
    MsgBox ""Please Fill In The Manager Field"", vbExclamation, ""Manager""
        UserForm1.TextBox7.SetFocus
        Exit Sub
    End If
   
   
    Dim Y As Integer
    Sheets(""Datasheet"").Range(""A2"").Value = UserForm1.TextBox2.Text
    Sheets(""Datasheet"").Range(""B2"").Value = UserForm1.TextBox4.Text
    Sheets(""Datasheet"").Range(""C2"").Value = UserForm1.TextBox1.Text
    Sheets(""Datasheet"").Range(""D2"").Value = CDate(UserForm1.TextBox8.Text)
   
    If UserForm1.OptionButton1.Value = True Then
        Y = Y + 1
        Sheets(""Datasheet"").Range(""E2"").Value = UserForm1.OptionButton1.Caption
    End If
    If UserForm1.OptionButton2.Value = True Then
        Y = Y + 1
        Sheets(""Datasheet"").Range(""E2"").Value = UserForm1.OptionButton1.Caption
    End If
    If UserForm1.OptionButton3.Value = True Then
        Y = Y + 1
        Sheets(""Datasheet"").Range(""E2"").Value = UserForm1.OptionButton1.Caption
    End If
    If UserForm1.OptionButton4.Value = True Then
        Y = Y + 1
        Sheets(""Datasheet"").Range(""E2"").Value = UserForm1.OptionButton1.Caption
    End If
    If UserForm1.OptionButton5.Value = True Then
        Y = Y + 1
        Sheets(""Datasheet"").Range(""F2"").Value = UserForm1.OptionButton1.Caption
    End If
    If UserForm1.OptionButton6.Value = True Then
        Y = Y + 1
        Sheets(""Datasheet"").Range(""F2"").Value = UserForm1.OptionButton1.Caption
    End If
    If UserForm1.OptionButton7.Value = True Then
        Y = Y + 1
        Sheets(""Datasheet"").Range(""F2"").Value = UserForm1.OptionButton1.Caption
    End If
    If UserForm1.OptionButton8.Value = True Then
        Y = Y + 1
        Sheets(""Datasheet"").Range(""F2"").Value = UserForm1.OptionButton1.Caption
    End If
    If UserForm1.OptionButton9.Value = True Then
        Y = Y + 1
        Sheets(""Datasheet"").Range(""G2"").Value = UserForm1.OptionButton1.Caption
    End If
    If UserForm1.OptionButton10.Value = True Then
        Y = Y + 1
        Sheets(""Datasheet"").Range(""G2"").Value = UserForm1.OptionButton1.Caption
    End If
    If UserForm1.OptionButton11.Value = True Then
        Y = Y + 1
        Sheets(""Datasheet"").Range(""G2"").Value = UserForm1.OptionButton1.Caption
    End If
    If UserForm1.OptionButton12.Value = True Then
        Y = Y + 1
        Sheets(""Datasheet"").Range(""G2"").Value = UserForm1.OptionButton1.Caption
    End If
    If UserForm1.OptionButton13.Value = True Then
        Y = Y + 1
        Sheets(""Datasheet"").Range(""H2"").Value = UserForm1.OptionButton1.Caption
    End If
    If UserForm1.OptionButton14.Value = True Then
        Y = Y + 1
        Sheets(""Datasheet"").Range(""H2"").Value = UserForm1.OptionButton1.Caption
    End If
    If UserForm1.OptionButton15.Value = True Then
        Y = Y + 1
        Sheets(""Datasheet"").Range(""H2"").Value = UserForm1.OptionButton1.Caption
    End If
    If UserForm1.OptionButton16.Value = True Then
        Y = Y + 1
        Sheets(""Datasheet"").Range(""H2"").Value = UserForm1.OptionButton1.Caption
    End If
    If UserForm1.OptionButton17.Value = True Then
        Y = Y + 1
        Sheets(""Datasheet"").Range(""I2"").Value = UserForm1.OptionButton1.Caption
    End If
    If UserForm1.OptionButton18.Value = True Then
        Y = Y + 1
        Sheets(""Datasheet"").Range(""I2"").Value = UserForm1.OptionButton1.Caption
    End If
    If UserForm1.OptionButton19.Value = True Then
        Y = Y + 1
        Sheets(""Datasheet"").Range(""I2"").Value = UserForm1.OptionButton1.Caption
    End If
    If UserForm1.OptionButton20.Value = True Then
        Y = Y + 1
        Sheets(""Datasheet"").Range(""I2"").Value = UserForm1.OptionButton1.Caption
    End If
    If UserForm1.OptionButton21.Value = True Then
        Y = Y + 1
        Sheets(""Datasheet"").Range(""J2"").Value = UserForm1.OptionButton1.Caption
    End If
    If UserForm1.OptionButton22.Value = True Then
        Y = Y + 1
        Sheets(""Datasheet"").Range(""J2"").Value = UserForm1.OptionButton1.Caption
    End If
    If UserForm1.OptionButton23.Value = True Then
        Y = Y + 1
        Sheets(""Datasheet"").Range(""J2"").Value = UserForm1.OptionButton1.Caption
    End If
    If UserForm1.OptionButton24.Value = True Then
        Y = Y + 1
        Sheets(""Datasheet"").Range(""J2"").Value = UserForm1.OptionButton1.Caption
    End If
    If UserForm1.OptionButton25.Value = True Then
        Y = Y + 1
        Sheets(""Datasheet"").Range(""K2"").Value = UserForm1.OptionButton1.Caption
    End If
    If UserForm1.OptionButton26.Value = True Then
        Y = Y + 1
        Sheets(""Datasheet"").Range(""K2"").Value = UserForm1.OptionButton1.Caption
    End If
    If UserForm1.OptionButton27.Value = True Then
        Y = Y + 1
        Sheets(""Datasheet"").Range(""K2"").Value = UserForm1.OptionButton1.Caption
    End If
    If UserForm1.OptionButton28.Value = True Then
        Y = Y + 1
        Sheets(""Datasheet"").Range(""K2"").Value = UserForm1.OptionButton1.Caption
    End If
    If UserForm1.OptionButton29.Value = True Then
        Y = Y + 1
        Sheets(""Datasheet"").Range(""L2"").Value = UserForm1.OptionButton1.Caption
    End If
    If UserForm1.OptionButton30.Value = True Then
        Y = Y + 1
        Sheets(""Datasheet"").Range(""L2"").Value = UserForm1.OptionButton1.Caption
    End If
    If UserForm1.OptionButton31.Value = True Then
        Y = Y + 1
        Sheets(""Datasheet"").Range(""L2"").Value = UserForm1.OptionButton1.Caption
    End If
    If UserForm1.OptionButton32.Value = True Then
        Y = Y + 1
        Sheets(""Datasheet"").Range(""L2"").Value = UserForm1.OptionButton1.Caption
    End If
    If UserForm1.OptionButton33.Value = True Then
        Y = Y + 1
        Sheets(""Datasheet"").Range(""M2"").Value = UserForm1.OptionButton1.Caption
    End If
    If UserForm1.OptionButton34.Value = True Then
        Y = Y + 1
        Sheets(""Datasheet"").Range(""M2"").Value = UserForm1.OptionButton1.Caption
    End If
    If UserForm1.OptionButton35.Value = True Then
        Y = Y + 1
        Sheets(""Datasheet"").Range(""M2"").Value = UserForm1.OptionButton1.Caption
    End If
    If UserForm1.OptionButton36.Value = True Then
        Y = Y + 1
        Sheets(""Datasheet"").Range(""M2"").Value = UserForm1.OptionButton1.Caption
    End If
    If UserForm1.OptionButton37.Value = True Then
        Y = Y + 1
        Sheets(""Datasheet"").Range(""N2"").Value = UserForm1.OptionButton1.Caption
    End If
    If UserForm1.OptionButton38.Value = True Then
        Y = Y + 1
        Sheets(""Datasheet"").Range(""N2"").Value = UserForm1.OptionButton1.Caption
    End If
    If UserForm1.OptionButton39.Value = True Then
        Y = Y + 1
        Sheets(""Datasheet"").Range(""N2"").Value = UserForm1.OptionButton1.Caption
    End If
    If UserForm1.OptionButton40.Value = True Then
        Y = Y + 1
        Sheets(""Datasheet"").Range(""N2"").Value = UserForm1.OptionButton1.Caption
    End If
    If UserForm1.OptionButton41.Value = True Then
        Y = Y + 1
        Sheets(""Datasheet"").Range(""O2"").Value = UserForm1.OptionButton1.Caption
    End If
    If UserForm1.OptionButton42.Value = True Then
        Y = Y + 1
        Sheets(""Datasheet"").Range(""O2"").Value = UserForm1.OptionButton1.Caption
    End If
    If UserForm1.OptionButton43.Value = True Then
        Y = Y + 1
        Sheets(""Datasheet"").Range(""O2"").Value = UserForm1.OptionButton1.Caption
    End If
    If UserForm1.OptionButton44.Value = True Then
        Y = Y + 1
        Sheets(""Datasheet"").Range(""O2"").Value = UserForm1.OptionButton1.Caption
    End If
    If Y <> 11 Then
        MsgBox ""You haven't answered all questions, please try again"", vbExclamation, ""Answer All Questions""
    End If
    Sheets(""Datasheet"").Range(""P2"").Value = UserForm1.TextBox5.Text
    Sheets(""Datasheet"").Range(""Q2"").Value = UserForm1.TextBox6.Text
    Sheets(""Datasheet"").Range(""R2"").Value = UserForm1.TextBox7.Text
    OpenFeedData
    Workbooks(""feed.xls"").Activate
    Rows(""2:2"").Select
    Selection.Copy
    Windows(""FEEDDATA.XLS"").Activate
    Range(""A1"").Select
    If IsEmpty(Range(""A2"")) Then
        Selection.Offset(1, 0).Select
    Else
        Selection.End(xlDown).Select
        Selection.Offset(1, 0).Select
    End If
    Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, _
    SkipBlanks:=False, Transpose:=False
    Range(""A1"").Select
    Workbooks(""Feeddata.xls"").Close savechanges = True
End Sub

Private Sub CommandButton2_Click()
    Workbooks(""Feed.xls"").Close savechanges = False
End Sub

Private Sub TextBox1_Change()

End Sub

Private Sub TextBox8_Change()
    If IsDate(TextBox8.Value) Then
    Label25.Visible = False
    Else
        Label25.Visible = True
        TextBox8.SetFocus
    End If
End Sub

Private Sub UserForm_Activate()
    TextBox1.Value = Format(Date, ""short date"")
    TextBox8.Value = Format(Date + 14, ""short date"")
End Sub
Function OpenFeedData()
    On Error GoTo ErrorHandler
    For X = 1 To 10000
        Workbooks.Open (""i:\users\jeed\data\xls\FeedData.xls"")
        X = 10000
    Next
Exit Function
ErrorHandler:
    Select Case Err.Number
        Case 55
            Resume
        Case Else
            Debug.Print Error(ErrorNumber)
    End Select
End Function




'UserForm2

Private Sub CommandButton1_Click()
UserForm1.Show

End Sub


Hope this helps

Frazer
0
DelboyAuthor Commented:
Thanks Steve, it works fine now..  I see the error of my ways..

Derek.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Office

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.