Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default EnableancelKey=xlErrorHandler not working in UserForm

I am runing XL97 in Win95.

I am trying to prevent a user from disabling a userform using
Ctrl-Break. I know how to stop him from clicking on the X but he can
still press Ctrl-Break and get out from the code..
I am using the code below to trap Ctrl-Break error 18 but it doesn't
work and I can't figure out why.

No matter what I do I don't seem to get it to go to the ErrorHandler
while UserForm1 is showing.

There isn't anything on that in MSKnowledgebase.
Thanks for any help.

'This is in ThisWorkbook
Private Sub Workbook_Open()
Call On_Open
End Sub

'This is in Module1
Private Sub On_Open()
On Error GoTo ErrorHandler
Application.EnableCancelKey = xlErrorHandler
UserForm1.Show
ErrorHandler:
If Err.Number = 18 Then
UserForm1.Hide
MsgBox "pressed break"
End If
End Sub



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default EnableancelKey=xlErrorHandler not working in UserForm

I wasn't able to get the error hander code to run either. But setting up
the error handler (even empty) along with EnableCancelKey = xlErrorHandler
does achieve what you want, doesn't it? It does not close the userform so
Ctrl-Break is effectively negated. You don't have to tell the user it
doesn't work; he can see that and will try something else.

--
Jim Rech
Excel MVP


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default EnableancelKey=xlErrorHandler not working in UserForm

The problem is that it doesn't get to the ErrorHandler line label.
Normally I would like to do some things when error 18 is discovered.
Display a warning message or save and close the workbook for example.
Just leaving it the way it is I had the code hang because it was
constantly displaying the user form.
Bottom line: xlErrorHandler does not seem to work as it is supposed to
and I wonder if any simple fixes, patches or workarounds exist.
On Mon, 19 Jan 2004 14:16:22 -0500, "Jim Rech"
wrote:

I wasn't able to get the error hander code to run either. But setting up
the error handler (even empty) along with EnableCancelKey = xlErrorHandler
does achieve what you want, doesn't it? It does not close the userform so
Ctrl-Break is effectively negated. You don't have to tell the user it
doesn't work; he can see that and will try something else.


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
Calculate working days but change working week SamB Excel Discussion (Misc queries) 1 September 1st 08 09:17 PM
Making weekend days working days - the system cuts the working tim Fluffy Excel Discussion (Misc queries) 1 May 30th 08 10:02 PM
one userform to another damorrison Excel Discussion (Misc queries) 2 August 26th 06 01:10 PM
Problem w/.EnableCancelKey = xlErrorHandler Nathan Gutman Excel Programming 0 January 16th 04 05:18 PM
Adding sales from a non working day to the previous working day Alex Excel Programming 1 September 19th 03 08:48 AM


All times are GMT +1. The time now is 04:53 AM.

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

About Us

"It's about Microsoft Excel"