On 2002-10-10 06:47, Bugs wrote:
Is there a way of deactivating Alt F11
Bugs...do you ONLY want to disable the Alt F11 OR are you really tying to disable access to the VBA Editor?
If you need to disable Access then
1st Option Protect your project.
Other wise use this Routine.
<PRE><FONT color=blue>Option Explicit</FONT>
<FONT color=#008000>'// Tested Excel2000
</FONT>
<FONT color=#008000>'// Run DisableGettingIntoVBE from a Event procedure
</FONT>
<FONT color=#008000>'// eg. Workbook_Open or Worksheet_Activate
</FONT>
<FONT color=#008000>'// THEN run EnableGettingIntoVBE from the Opp Event procedure
</FONT>
<FONT color=#008000>'// eg. Workbook_Close or Worksheet_Deactivate
</FONT>
<FONT color=#008000>'//=====================================================================
</FONT>
<FONT color=#008000>'// Note:
</FONT>
<FONT color=#008000>'// In order to Disable access into the VBA Editor
</FONT>
<FONT color=#008000>'// you must Disable ALL references to Access the code
</FONT>
<FONT color=#008000>'// eg Macros...dialog,View Code - available via RighClick on Sheet Tab
</FONT>
<FONT color=#008000>'// Record New Macro..., and also Design Mode as the User can put the
</FONT>
<FONT color=#008000>'// workbook in design mode then select a control & double clcik to
</FONT>
<FONT color=#008000>'// view code. Alo you need to Disable the Custom Toolbar List AND
</FONT>
<FONT color=#008000>'// the fact that Double clicking ANY area of the commandbars will
</FONT>
<FONT color=#008000>'// also give you the Customize Toolbars Option Dialog.
</FONT>
<FONT color=#008000>'// The following Routine Takes care of this.
</FONT>
<FONT color=blue>Sub </FONT>DisableGettingIntoVBE()
Application.VBE.MainWindow.Visible =<FONT color=blue> False</FONT> <FONT color=#008000>'// Close ALL windows 1st!
</FONT>
CmdControl 1695,<FONT color=blue> False</FONT> <FONT color=#008000>'// Visual basics Editor
</FONT>
CmdControl 186,<FONT color=blue> False</FONT> <FONT color=#008000>'// Macros...
</FONT>
CmdControl 184,<FONT color=blue> False</FONT> <FONT color=#008000>'// Record New Macro...
</FONT>
CmdControl 1561,<FONT color=blue> False</FONT> <FONT color=#008000>'// View Code
</FONT>
CmdControl 1605,<FONT color=blue> False</FONT> <FONT color=#008000>'// Design Mode
</FONT>
Application.OnDoubleClick = "Dummy"
CommandBars("ToolBar List").Enabled =<FONT color=blue> False</FONT>
Application.OnKey "%{F11}", "Dummy"
<FONT color=blue>End Sub</FONT>
<FONT color=blue>Sub </FONT>EnableGettingIntoVBE()
CmdControl 1695,<FONT color=blue> True</FONT> <FONT color=#008000>'// Visual basics Editor
</FONT>
CmdControl 186,<FONT color=blue> True</FONT> <FONT color=#008000>'// Macros...
</FONT>
CmdControl 184,<FONT color=blue> True</FONT> <FONT color=#008000>'// Record New Macro...
</FONT>
CmdControl 1561,<FONT color=blue> True</FONT> <FONT color=#008000>'// View Code
</FONT>
CmdControl 1605,<FONT color=blue> True</FONT> <FONT color=#008000>'// Design Mode
</FONT>
Application.OnDoubleClick = ""
CommandBars("ToolBar List").Enabled =<FONT color=blue> True</FONT>
Application.OnKey "%{F11}", ""
<FONT color=blue>End Sub</FONT>
<FONT color=blue>Sub </FONT>CmdControl(Id <FONT color=blue>As</FONT><FONT color=blue> Integer</FONT>, TF <FONT color=blue>As</FONT> <FONT color=blue>Boolean</FONT>)
<FONT color=blue>Dim </FONT>CBar <FONT color=blue>As</FONT> CommandBar
<FONT color=blue>Dim </FONT>C <FONT color=blue>As</FONT> CommandBarControl
<FONT color=blue>On Error</FONT> <FONT color=blue>Resume </FONT><FONT color=blue>Next</FONT>
<FONT color=blue>For </FONT>Each CBar In Application.CommandBars
<FONT color=blue>Set </FONT>C = CBar.FindControl(Id:=Id, recursive:=True)
<FONT color=blue>If </FONT>Not C Is<FONT color=blue> Nothing</FONT><FONT color=blue> Then </FONT>C.Enabled = TF
<FONT color=blue>Next</FONT>
<FONT color=blue>End Sub</FONT>
<FONT color=blue>Sub </FONT>Dummy()
<FONT color=#008000> '// NoGo, leave blank OR Display a message eg.
</FONT>
<FONT color=#008000> 'MsgBox "Sorry you this command is NOT available", vbCritical
</FONT>
<FONT color=blue>End Sub</FONT>
</PRE>