Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default Prevent Escape on Nonmodal Userform with Progressbar

Is there any way to use a progressbar control in a modal userform?

I need to block users from accessing Excel or interrupting code execution by
pressing Escape
while a progressbar is being displayed.

Pressing Escape while a nonmodal userform is active returns €śCode execution
has been interrupted.€ť Pressing Escape while a modal userform is active does
the same thing as the Cancel button if a Cancel button control is present.

I tried capturing the keydown event with the following code, but the code
gets interrupted before it can capture the keycode:
Private Sub UserForm_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal
Shift As Integer)
If KeyCode = vbKeyEscape Then Unload Me
End Sub

Either I need to be able to display a progressbar control in a modal
userform, or I need to be able to capture the Escape KeyDown event.

Thanks for your help.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Prevent Escape on Nonmodal Userform with Progressbar

Have you tried using the following line of code?
Application.EnableCancelKey = xlDisabled

This stops Ctrl+Break from interrupting code execution and I think it will
work in your case as well.

Andy

"Lazzaroni" wrote:

Is there any way to use a progressbar control in a modal userform?

I need to block users from accessing Excel or interrupting code execution by
pressing Escape
while a progressbar is being displayed.

Pressing Escape while a nonmodal userform is active returns €śCode execution
has been interrupted.€ť Pressing Escape while a modal userform is active does
the same thing as the Cancel button if a Cancel button control is present.

I tried capturing the keydown event with the following code, but the code
gets interrupted before it can capture the keycode:
Private Sub UserForm_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal
Shift As Integer)
If KeyCode = vbKeyEscape Then Unload Me
End Sub

Either I need to be able to display a progressbar control in a modal
userform, or I need to be able to capture the Escape KeyDown event.

Thanks for your help.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default Prevent Escape on Nonmodal Userform with Progressbar

Andy:

Private Sub UserForm_Activate()
With Application
.Interactive = False
.EnableCancelKey = xlDisabled
End With
End Sub

The above code approximates a modal form, which is what I needed.

I would have liked to allow the user to use the Escape key in addition to
being able to click on the Cancel button, but EnableCancelKey = xlDisabled
prevents me from trapping the keycode as well, so the following code does not
work.

Private Sub UserForm_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal
Shift As Integer)
If KeyCode = vbKeyEscape Then Unload Me
End Sub

I will try looking for a EnableCancelKey = xlErrorHandler workaround, but
ideally, I would like to run my user form with ShowModal = True.
Unfortunately, I havent found a way to display a progressbar control
correctly in a modal userform.

For the time being, this does the trick. Thank you for your suggestion.
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
Progressbar on userform for waiting querytable retrieving data from web [email protected] Excel Programming 4 July 11th 07 02:58 AM
ProgressBar control in Userform Charlie Excel Programming 7 October 21st 05 11:47 PM
NonModal Forms and Set Focus JimP Excel Programming 0 November 24th 04 02:56 AM
MODAL vs. NonMODAL JimP Excel Programming 5 November 18th 04 01:21 PM
using escape key to exit a userform heidi Excel Programming 3 June 4th 04 05:25 PM


All times are GMT +1. The time now is 05:10 AM.

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"