Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disable CTRL+BREAK 2

Status
Not open for further replies.

JVerdaasdonk

Instructor
Joined
Jan 18, 2004
Messages
72
Location
NL
Hi,

I'm building a Word Wizard.
In the form code I need some code that will prevent users from stopping the procedure.

Is it possible to dissable the following functions: (and later put them back!)

CTRL+BREAK
ALT+F4
ESCAPE

Am I missing something.......? Or am I going about this the wrong way?

Please advise?

Regards,
J.Verdaasdonk
 
Application.EnableCancelKey =
wdCancelDisabled ' locks CTRL+BREAK (and other)
wdCancelInterrupt ' activates CTRL+BREAK

combo
 
Take a look at the UserForm_QueryClose event.

Hope This Help
PH.
 
Hi Combo,

Thnxx, for the tip...but?

Where should I put this code? (can I put it in Intialize?)

Would you be so kind as to write the entire code for the other key-combinations also? (you're writing and other, but this a new subject for me, and I've haven't got a clue)

Could you also Explane with some comment rules what the code does? And does this code put the function back at the end. (or does that happens automatic)

Thank you so much!

J.Verdaasdonk
 
Hi PH,

I'm looking at it in F1, but it seems this procedure only has 5 constants. (are these the functions I'm looking for?)

Am I wrong, are the key-combinations mentioned above on Call in this sub?

How should I use this...(I don't know)

Thnxxx,
J.Verdaasdonk
 
It is setting of Application property, so you can write it in initialize event. I went too far with "and other" - it only locks/unlocks breaking of code execution.
I think that PHV's solution can be more convinient for you, especially with EnableCancelKey. You can force user to close form using buttons and lock other ways. The code:

[tt]Private Sub UserForm_Initialize()
Application.EnableCancelKey = wdCancelDisabled
End Sub

Private Sub CloseButton_Click()
Application.EnableCancelKey = wdCancelInterrupt
Unload Me
End Sub

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode <> vbFormCode Then Cancel = True
End Sub[/tt]

combo
 
Hi Combo, (and PH for helping)[2thumbsup]

This code works brilliantly!

Thank you for you're time, I truly appreciate the effort you put in to this question.

Regards,
Joost
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top