PC Review


Reply
Thread Tools Rate Thread

Disable the PauseBreak key

 
 
leerem
Guest
Posts: n/a
 
      15th Jul 2009
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
 
Reply With Quote
 
 
 
 
AB
Guest
Posts: n/a
 
      15th Jul 2009
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 <lee...@discussions.microsoft.com> 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


 
Reply With Quote
 
leerem
Guest
Posts: n/a
 
      15th Jul 2009
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 <lee...@discussions.microsoft.com> 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

>
>

 
Reply With Quote
 
AB
Guest
Posts: n/a
 
      15th Jul 2009
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 <lee...@discussions.microsoft.com> 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 <lee...@discussions.microsoft.com> 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 userformwill be
> > > lost.

>
> > > your help would be appreciated
> > > lee- Hide quoted text -

>
> - Show quoted text -


 
Reply With Quote
 
AB
Guest
Posts: n/a
 
      15th Jul 2009
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 <austris.bahanovs...@gmail.com> 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 itneeds
> 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 <lee...@discussions.microsoft.com> 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 <lee...@discussions.microsoft.com> 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. Shouldthis
> > > > 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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
if I disable ssdp with this disable upnp for my router? jim Windows XP General 2 31st Jan 2007 08:15 AM
if I disable ssdp with this disable upnp for my router? jim Windows XP Help 2 31st Jan 2007 08:15 AM
Performing something Like Disable / changing the layout of Disable esakal Microsoft C# .NET 0 6th Sep 2006 05:01 PM
Disable Password Prompt/Disable User Lock =?Utf-8?B?SnVsY28=?= Windows XP General 2 25th Aug 2006 02:05 AM
Skin pocket pc, disable hardware buttons, disable start button Tizio Incognito Microsoft Dot NET Compact Framework 1 3rd Feb 2005 09:13 AM


Features
 

Advertising
 

Newsgroups
 


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