UserForm Prob

  • Thread starter Thread starter YoureNotAtHomeNow
  • Start date Start date
Y

YoureNotAtHomeNow

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




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

Private Sub CommandButton1_Click()
[code here seems to be working]
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.
 
Back
Top