Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
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. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Concatenation prob | Excel Programming | |||
Concatenation prob | Excel Programming | |||
Concatenation prob | Excel Programming | |||
Anyone see the prob in this code? | Excel Programming | |||
Anyone see the prob in this code? | Excel Programming |