Solved

Corrupt Excel Workbook

Posted on 1998-08-12
13
325 Views
Last Modified: 2012-06-21
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
0
Comment
Question by:Delboy
  • 5
  • 4
  • 2
  • +1
13 Comments
 
LVL 1

Expert Comment

by:awd
ID: 1613104
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
 

Author Comment

by:Delboy
ID: 1613105
This only stops the AutoOpen macro, but still cannot get into the visual basic editor without crashing once in the workbook...
0
 
LVL 1

Expert Comment

by:awd
ID: 1613106
I see. I misunderstood your problem. I will give it some more thought.
0
 

Author Comment

by:Delboy
ID: 1613107
I look forward to it..  D.
0
 
LVL 3

Expert Comment

by:shalbe
ID: 1613108
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
 
LVL 1

Expert Comment

by:awd
ID: 1613109
Delboy,

What happens when it crashes?
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

Author Comment

by:Delboy
ID: 1613110
It crashes Excel altogether...
0
 
LVL 3

Expert Comment

by:frazer
ID: 1613111
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
 
LVL 1

Expert Comment

by:awd
ID: 1613112
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
 

Author Comment

by:Delboy
ID: 1613113
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
 
LVL 3

Accepted Solution

by:
shalbe earned 200 total points
ID: 1613114
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
 
LVL 3

Expert Comment

by:frazer
ID: 1613115
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
 

Author Comment

by:Delboy
ID: 1613116
Thanks Steve, it works fine now..  I see the error of my ways..

Derek.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Using Word 2013, I was experiencing some incredible lag when typing.  Here's what worked for me....
In this article we discuss how to recover the missing Outlook 2011 for Mac data like Emails and Contacts manually.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

708 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

16 Experts available now in Live!

Get 1:1 Help Now