ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   UserForm Prob (https://www.excelbanter.com/excel-programming/415428-userform-prob.html)

[email protected]

UserForm Prob
 
Userform1 has 3 option buttons & a Command Button. I've got this:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)

' ASK IF EMAILS NEED SENDING WHEN AMENDMENTS/ADDITIONS MADE

' ALWAYS RETURN TO TOP OF VIEW OR PRINT SHEET B4 CLOSING
Sheets("VIEW OR PRINT").Select
ActiveWindow.ScrollRow = 1
Cells(1, 1).Select

UserForm1.Show

End Sub

....then...

Private Sub CommandButton1_Click()

[code here seems to be working]

End Sub

When I Save (ie activate the macro), I get a Runtime error '400' and
UserForm1.Show is yellow-highlighted. I've tried putting Unload
UserForm1 in under UserForm1.Show



JLGWhiz

UserForm Prob
 
Sometimes when the problem is in the code for a control on the UserForm it is
hard to detect, because the highlight for the debug interrupt reverts to the
UserForm.Show line of code. You would need to step through the code line by
line to find where it actually throws the error. I suspect you will find it
is in the code behind one of the controls on the UserForm.

" wrote:

Userform1 has 3 option buttons & a Command Button. I've got this:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)

' ASK IF EMAILS NEED SENDING WHEN AMENDMENTS/ADDITIONS MADE

' ALWAYS RETURN TO TOP OF VIEW OR PRINT SHEET B4 CLOSING
Sheets("VIEW OR PRINT").Select
ActiveWindow.ScrollRow = 1
Cells(1, 1).Select

UserForm1.Show

End Sub

....then...

Private Sub CommandButton1_Click()

[code here seems to be working]

End Sub

When I Save (ie activate the macro), I get a Runtime error '400' and
UserForm1.Show is yellow-highlighted. I've tried putting Unload
UserForm1 in under UserForm1.Show




Rick Rothstein \(MVP - VB\)[_2525_]

UserForm Prob
 
Why are you showing your UserForm before saving (and closing, according to
your notes)? Depending on what code gets run when the UserForm loads and
activates, I can imagine some problems that could come up. Why not move the
UserForm.Show statement to the Workbook_Open event and remove it from your
Workbook_BeforeSave event? That should still function the way you want
without the possibility of "side effects" from loading the UserForm before
closing.

Rick


wrote in message
...
Userform1 has 3 option buttons & a Command Button. I've got this:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)

' ASK IF EMAILS NEED SENDING WHEN AMENDMENTS/ADDITIONS MADE

' ALWAYS RETURN TO TOP OF VIEW OR PRINT SHEET B4 CLOSING
Sheets("VIEW OR PRINT").Select
ActiveWindow.ScrollRow = 1
Cells(1, 1).Select

UserForm1.Show

End Sub

...then...

Private Sub CommandButton1_Click()

[code here seems to be working]

End Sub

When I Save (ie activate the macro), I get a Runtime error '400' and
UserForm1.Show is yellow-highlighted. I've tried putting Unload
UserForm1 in under UserForm1.Show




[email protected]

UserForm Prob
 
On Aug 9, 6:45*pm, "Rick Rothstein \(MVP - VB\)"
wrote:
Why are you showing your UserForm before saving (and closing, according to
your notes)? Depending on what code gets run when the UserForm loads and
activates, I can imagine some problems that could come up. Why not move the
UserForm.Show statement to the Workbook_Open event and remove it from your
Workbook_BeforeSave event? That should still function the way you want
without the possibility of "side effects" from loading the UserForm before
closing.

Rick

wrote in message

...



Userform1 has 3 option buttons & a Command Button. *I've got this:


Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)


' * ASK IF EMAILS NEED SENDING WHEN AMENDMENTS/ADDITIONS MADE


' * ALWAYS RETURN TO TOP OF VIEW OR PRINT SHEET B4 CLOSING
* *Sheets("VIEW OR PRINT").Select
* *ActiveWindow.ScrollRow = 1
* *Cells(1, 1).Select


* *UserForm1.Show


End Sub


...then...


Private Sub CommandButton1_Click()


[code here seems to be working]


End Sub


When I Save (ie activate the macro), I get a Runtime error '400' and
UserForm1.Show is yellow-highlighted. *I've tried putting Unload
UserForm1 in under UserForm1.Show- Hide quoted text -


- Show quoted text -


Thanks, all. Got it going now.


All times are GMT +1. The time now is 06:03 PM.

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