excell error on close with commandbutton

P

pswanie

i got a userform with a command button. (caption "close") used to work fine.
but i worked on it just now. not the button code it self and not even in the
workbook before close.

now when i click the close button i get

-----------------------------------------------
microsoft office excel has encountered a problem and needs to close
---------------------------------------------------------------

i exported the 4 userforms and 6 modules and copy the pages in a new
workbook. renamed and imported the userform and modules. then it stoped for
a couple times but back now again....

here is some of my code

Private Sub Workbook_Open()
Sheets("Sheet1").Select
Worksheets("sheet1").Range("K4").Value = False
Worksheets("sheet1").Range("K5").Value = False
Worksheets("sheet1").Range("K6").Value = False
Worksheets("sheet1").Range("K7").Value = False
Worksheets("sheet1").Range("K8").Value = False


With Application
.Calculation = xlCalculationAutomatic
.MaxChange = 0.001
End With

Application.Visible = False



UserForm1.Show

UserForm1.TextBox1.Value = ""
UserForm1.CheckBox1.Value = False
UserForm1.CheckBox2.Value = False
UserForm1.CheckBox3.Value = False
UserForm1.CheckBox4.Value = False
UserForm1.CheckBox5.Value = False


End Sub
--------------------------------------------------------------------------
Private Sub Workbook_BeforeClose(Cancel As Boolean)

ActiveWorkbook.Save

Application.Visible = True

End Sub

-------------------------------------------------------------------------------

Private Sub CommandButton4_Click()

Unload UserForm1
Sheets("Sheet1").Select
ActiveWorkbook.Save
Application.Quit
End Sub
 
P

pswanie

still crash even if i make it visible first....

Nigel said:
Not sure you can Select a sheet when the application is invisible?

--

Regards,
Nigel
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top