|
| View previous topic :: View next topic |
| Author |
Message |
Bear Guest
|
Posted: Fri Dec 21, 2007 11:34 pm Post subject: Calling a UserForm Exit sub |
|
|
I have some code I'd like to execute when a command button is clicked. The
code is in the exit subroutine of a text box.
Private Sub txtColumnWidth_Exit(ByVal Cancel As MSForms.ReturnBoolean)
But when I say
Call txtColumnWidth_Exit
the compiler insists that I provide the Cancel argument. But I can't figure
out how to do that. None of these work, giving a type mismatch error on
compile.
Call txtColumnWidth_Exit(Cancel:=True)
Call txtColumnWidth_Exit(Cancel:=1)
What type is MSForms.ReturnBoolean and how do I pass it?
Bear
--
Windows XP, Word 2000 |
|
| Back to top |
|
 |
Google Sponsor

|
Posted: Fri Dec 21, 2007 11:34 pm Post subject: Advertisement |
|
|
|
|
| Back to top |
|
 |
Jay Freedman Guest
|
Posted: Sat Dec 22, 2007 1:23 am Post subject: Re: Calling a UserForm Exit sub |
|
|
Hi Bear,
The point is moot, because _you_ shouldn't be calling the Exit
routine. It's an event handler, so VBA calls it automatically when the
event occurs (the textbox loses focus), and it takes care of
(invisibly) declaring the Cancel argument and using whatever value it
has when the handler returns.
Really, though, if you want "some code I'd like to execute when a
command button is clicked", then that code should be in the button's
_Click() procedure, not in the text box's _Exit() procedure. You can't
be sure that exiting the text box means that the button has been
clicked... maybe the user clicked a blank area of the userform (and
yes, there's an event handler for that, too).
On Fri, 21 Dec 2007 15:34:04 -0800, Bear
<david.chinell@ge.com(nospam)> wrote:
| Quote: | I have some code I'd like to execute when a command button is clicked. The
code is in the exit subroutine of a text box.
Private Sub txtColumnWidth_Exit(ByVal Cancel As MSForms.ReturnBoolean)
But when I say
Call txtColumnWidth_Exit
the compiler insists that I provide the Cancel argument. But I can't figure
out how to do that. None of these work, giving a type mismatch error on
compile.
Call txtColumnWidth_Exit(Cancel:=True)
Call txtColumnWidth_Exit(Cancel:=1)
What type is MSForms.ReturnBoolean and how do I pass it?
Bear
|
--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|