View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
Zone Zone is offline
external usenet poster
 
Posts: 269
Default Enable ESC to canel UserForm

Glad you got it figured out, Jay. The behavior is a little unexpected.
Cheers! James
Jay wrote:
Hold the presses, James. The answer was in your first response. Put the
button outside of the multipage control. In fact, don't bother hiding behind
any controls. It just gets 'sticky' and there is some unpredictable
interaction with the multipage control.

The solution to making a 'visible' button 'invisibile' - while still
allowing it to fire a click event when ESC is pushed - lies in first
oversizing the form grid during the design stage. You can put the Cancel
button at the bottom of the grid (or a healthy distance below the controls
you want the user to see). Then, drag the lower edge of the form up so that
the button is outside the lower boundary of what he user will see. The
button remains functional and the user can't see it. Then the user has the
option of using the mouse or pressing escape to cancel the form.

Thanks for your help. Hope to solve another one with you in the future.
---
Jay


"Jay" wrote:

I'd like to enable the Escape key to cancel a userform. My form has a single
multipage control with two pages.

I have inserted a commandbutton with its Cancel property set to True and
have hidden the commandbutton by sending it behind the Multipage control.
Its Click event is:

Private Sub CommandButton1_Click()
Unload Me
Set frmInstructions = Nothing
End Sub

I encounter two problems with this: First, the Escape key unloads the form
only when the second page of the multipage is visible (I'd like Esc to cancel
the form at any point). Second, I can't select the button for editing after
it is hidden behind the multipage (need definitive selection method).

--
Thanks in Advance,
Jay