ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   excell error on close with commandbutton (https://www.excelbanter.com/excel-programming/406272-excell-error-close-commandbutton.html)

pswanie

excell error on close with commandbutton
 
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



Nigel[_2_]

excell error on close with commandbutton
 
Not sure you can Select a sheet when the application is invisible?

--

Regards,
Nigel




"pswanie" wrote in message
...
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




pswanie

excell error on close with commandbutton
 
still crash even if i make it visible first....

"Nigel" wrote:

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

--

Regards,
Nigel




"pswanie" wrote in message
...
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





All times are GMT +1. The time now is 07:31 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com