?
Solved

Corrupt Excel Workbook

Posted on 1998-08-12
13
Medium Priority
?
361 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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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
 

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 800 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

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.

Join & Write a Comment

Read this tutorial to learn how to fix repeating password error prompts when setting up Gmail IMAP with Microsoft Outlook. The entire process is described with step by step, illustrated instructions. Enjoy...
Get to Know about Lotus Notes email migration to Office 365 in detail. Explore the article for better Lotus Notes to Office 365 migration techniques to transfer all data items to the O365 domain.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…

568 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