Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Concatenation prob Don Guillett Excel Programming 1 August 2nd 07 06:56 PM
Concatenation prob Rick Rothstein \(MVP - VB\) Excel Programming 0 July 11th 07 09:22 PM
Concatenation prob Rick Rothstein \(MVP - VB\) Excel Programming 1 July 10th 07 07:02 PM
Anyone see the prob in this code? Joseph[_44_] Excel Programming 0 October 1st 04 03:18 PM
Anyone see the prob in this code? Joseph[_43_] Excel Programming 2 October 1st 04 02:47 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"