View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Andy Wiggins Andy Wiggins is offline
external usenet poster
 
Posts: 107
Default Disabling Ctrl, ALT keys

See inline comments

--

Regards
Andy Wiggins
www.BygSoftware.com
Home of "Save and BackUp",
"The Excel Auditor" and "Byg Tools for VBA"


"turk5555" wrote in message
...

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)


The code was tested in Excel XP before posting - it works in XP - which
version are you using?

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.


Here are the notes from my first answer together with the Activate and
DeActivate procedures. Did you use them?

.... You also need to consider what happens when a user moves to and from
that
workbook to another. These procedures (again placed in "ThisWorkboo") will
only allow the keys to be disabled when your main workbook is active.

Private Sub Workbook_Activate()
TestDisableOnKey
End Sub

Private Sub Workbook_Deactivate()
TestEnableOnKey
End Sub