Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Disable the PauseBreak key
gentelmen,
I'm working on a spreadsheet that is primarily run by code, by use of userforms. What i need is to stop some inquisitive personell from attempting to break out of the code by the use of Control + PauseBreak keys. How can I therefore Disable this combination of key strokes. Should this occur all the information held within memory on the specific userform will be lost. your help would be appreciated lee |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Disable the PauseBreak key
check out
application.EnableCancelKey You can set it to enable/disable/Error and then code accordingly. The 'error' let's you trap it by raising an error - i think the err.number=18. On Jul 15, 2:26*pm, leerem wrote: gentelmen, * * * * * * I'm working on a spreadsheet that is primarily run by code, by use of userforms. What i need is to stop some inquisitive personell from attempting to break out of the code by the use of Control + PauseBreak keys. How can I therefore Disable this combination of key strokes. Should this occur all the information held within memory on the specific userform will be lost. your help would be appreciated lee |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Disable the PauseBreak key
Hi,
thanks for the info I've tried placing some code in the Userform Terminate section but it wont launch upon the keystroke combination. Would i be asking too much if you could supply some code and at what section would this be applied many thanks "AB" wrote: check out application.EnableCancelKey You can set it to enable/disable/Error and then code accordingly. The 'error' let's you trap it by raising an error - i think the err.number=18. On Jul 15, 2:26 pm, leerem wrote: gentelmen, I'm working on a spreadsheet that is primarily run by code, by use of userforms. What i need is to stop some inquisitive personell from attempting to break out of the code by the use of Control + PauseBreak keys. How can I therefore Disable this combination of key strokes. Should this occur all the information held within memory on the specific userform will be lost. your help would be appreciated lee |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Disable the PauseBreak key
This code worked for me on a userform1 with CommandButton1 :
'Userform module: Private Sub CommandButton1_Click() Me.Hide Dim rng As Range On Error GoTo CanclErr: Application.EnableCancelKey = xlErrorHandler For Each rng In ActiveSheet.Cells If rng.Row = 2000 Then GoTo ExtFinished: 'Just to kill it it when it takes too long - for ilustration puroposses only rng.Value = 1' Obviously your code would do whatever it needs to do Next ExtFinished: Exit Sub CanclErr: MsgBox "Nope, you should not be cancelling this!" Stop 'This is here just so that you could see when it traps the error. You don't need it in your final code. Resume End Sub '''''''''''''' 'Standard module: Sub tryCancel() UserForm1.Show End Sub Give it a try. On Jul 15, 3:58*pm, leerem wrote: Hi, thanks for the info I've tried placing some code in the Userform Terminate section but it wont launch upon the keystroke combination. Would i be asking too much if you could supply some code and at what section would this be applied many thanks "AB" wrote: check out application.EnableCancelKey You can set it to enable/disable/Error and then code accordingly. The 'error' let's you trap it by raising an error - i think the err.number=18. On Jul 15, 2:26 pm, leerem wrote: gentelmen, * * * * * * I'm working on a spreadsheet that is primarily run by code, by use of userforms. What i need is to stop some inquisitive personell from attempting to break out of the code by the use of Control + PauseBreak keys. How can I therefore Disable this combination of key strokes. Should this occur all the information held within memory on the specific userform will be lost. your help would be appreciated lee- Hide quoted text - - Show quoted text - |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Disable the PauseBreak key
Forgot to mention that you don't need this:
Me.Hide in the code in case your form isn't Modal. I don't know if you can change that on the fly - would need to do some research on that one. This would matter to you if you want to trap the Esc instead of just disabling it. On Jul 15, 4:47*pm, AB wrote: This code worked for me on a userform1 with CommandButton1 : 'Userform module: Private Sub CommandButton1_Click() * * Me.Hide * * Dim rng As Range * * On Error GoTo CanclErr: * * Application.EnableCancelKey = xlErrorHandler * * For Each rng In ActiveSheet.Cells * * * * If rng.Row = 2000 Then GoTo ExtFinished: 'Just to kill it it when it takes too long - for ilustration puroposses only * * * * rng.Value = 1' Obviously your code would do whatever it needs to do * * Next ExtFinished: * * Exit Sub CanclErr: * * MsgBox "Nope, you should not be cancelling this!" * * Stop 'This is here just so that you could see when it traps the error. You don't need it in your final code. * * Resume End Sub '''''''''''''' 'Standard module: Sub tryCancel() * *UserForm1.Show End Sub Give it a try. On Jul 15, 3:58*pm, leerem wrote: Hi, thanks for the info I've tried placing some code in the Userform Terminate section but it wont launch upon the keystroke combination. Would i be asking too much if you could supply some code and at what section would this be applied many thanks "AB" wrote: check out application.EnableCancelKey You can set it to enable/disable/Error and then code accordingly. The 'error' let's you trap it by raising an error - i think the err.number=18. On Jul 15, 2:26 pm, leerem wrote: gentelmen, * * * * * * I'm working on a spreadsheet that is primarily run by code, by use of userforms. What i need is to stop some inquisitive personell from attempting to break out of the code by the use of Control + PauseBreak keys. How can I therefore Disable this combination of key strokes. Should this occur all the information held within memory on the specific userform will be lost. your help would be appreciated lee- Hide quoted text - - Show quoted text -- Hide quoted text - - Show quoted text - |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Disable ALT+F11 | Excel Programming | |||
Disable # | Excel Discussion (Misc queries) | |||
Disable alt+tab | Excel Programming | |||
Disable Alt+F11 | Excel Discussion (Misc queries) | |||
disable F1 after F2 | Excel Programming |