View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
turk5555[_5_] turk5555[_5_] is offline
external usenet poster
 
Posts: 1
Default Disabling Ctrl, ALT keys

This is the code that I added in ThisWorkbook:

Private Sub Workbook_Open()
Application.OnKey "%{F11}", ""
Application.OnKey "%{F8}", ""
End Sub

Private Sub App_WorkbookBeforeClose(ByVal Wb As Workbook, _
Cancel As Boolean)

TestEnableOnKey

End Sub

This code disables the shortcut key ALT+F8 which displays the MACROS
list box and the shortcut key ALT+F11 which displays the Visual Basic
Editor. (NOTE: Your original code for enabling the shortcut keys upon
closing the workbook was not correct. I found the above version that
works)

When I open the workbook (workbook 1) that contains the above code this
works fine. If I open another workbook (workbook 2), and try to use
the above shortcut keys these shortcut keys remain disabled.

If I close the workbook 1, these shortcut keys remain disabled and I
can't use them in workbook 2. In order to enable these shortcut keys
it is necessary to close workbook 2 and closedown (exit) Excel, then
open workbook 1 and closedown Excel again.
When I open workbook 2 the shortcut keys are enabled.

Weird, but at least I understand what happens.

Thanks for all your help.



Tommy


---
Message posted from http://www.ExcelForum.com/