Disable F1 key

irchris

New Member
Joined
Nov 29, 2005
Messages
7
Does anyone know if it's possible to disable access to help via the f1 key, but still retain access to it on the drop down menus?
 

Some videos you may like

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

Greg Truby

MrExcel MVP
Joined
Jun 19, 2002
Messages
10,014
Yes, using VBA you can. But why? That will annoy most users. Are you going to disable it on the main menu as well?
 

Russ At Index

Well-known Member
Joined
Sep 23, 2002
Messages
670
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
  2. MacOS
Hi irchris,

Try this code................

Sub Workbook_Activate()
Application.OnKey "{F1}"
End Sub

HTH

Russ
 

Greg Truby

MrExcel MVP
Joined
Jun 19, 2002
Messages
10,014
Russ, close, but it would need to look like this:

<font face=Courier New><SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> Workbook_Activate()
    Application.OnKey "{F1}", vbNullString
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN>

<SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> Workbook_Deactivate()
    Application.OnKey "{F1}"
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN>
</FONT>

This assumes that irchris (a) knows how to get to the VBE and (b) how to get to the workbook's code page. Note that this is only his third post here.
 

irchris

New Member
Joined
Nov 29, 2005
Messages
7

ADVERTISEMENT

Thanks for the replies.

I guess I should clarify a bit. Sometimes when I go to hit the Esc key, but hit the f1 key instead. That results in the wait for help to come up. I find it very irritating when I'm trying to get work done.

I'm not so much looking to disable it in a specific workbook, but for any Excel file I bring up on my PC.

Oh yeah, I'm using Excel 2000.
 

Greg Truby

MrExcel MVP
Joined
Jun 19, 2002
Messages
10,014
In that case you'd want to add the following to your personal macro workbook. (See below if you are unfamiliar with this process.)

<font face=Courier New><SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> Workbook_Open()
    Application.OnKey "{F1}", vbNullString
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT><hr />

To add code to a workbook:
  1. Alt+F11 to get to the Visual Basic Editor (VBE).
  2. From the VBE menu Insert|Module
  3. Add in code (copy and paste).
  4. Alt+F11 again to jump back to Excel.
  5. Alt+F8 then pick the macro from the list.
Note: It's usually a good idea to save your work before running new macros.<hr>If you wish to always have the macro available and not just when one particular workbook is open - i.e. the macro is a "generic" macro; it is better to place the macro in your Personal Macro Workbook. This is a workbook that Excel automatically creates. If you use the Macro Recorder to record a macro, the dialog box asks where you want to store the macro: (a) the active wb, (b) a new wb or (c) in your Personal Macro wb. If you select Personal Macro Workbook and you have not previously recorded a macro there, Excel will create it for you, naming it Personal.xls and placing it in your Excel startup directory. This way every time you start Excel, Personal.xls will load and its macros will be available to you. (Note that Personal.xls is a hidden workbook and not an Excel Add-In.)
 

Greg Truby

MrExcel MVP
Joined
Jun 19, 2002
Messages
10,014

ADVERTISEMENT

Meant to add this...

This code needs to go into the Workbook Code Module and not a Standard Module. In the VBE you should see a list of VB projects, including your personal macro workbook. If you do not, then hit Ctrl+R to activate the Project Explorer window. If it is collapsed, expand the item for your personal macro workbook. You should see a small XL icon and ThisWorkbook. Double click that to open the workbook code module. If you are in the correct spot, then the VBE's title bar should have "ThisWorkbook (Code)" in brackets at the end of the application title.

HTH
 

irchris

New Member
Joined
Nov 29, 2005
Messages
7
Greg and Russ,

Got the macro working on startup. I appreciate your help.

Thanks,
Chris
 

aequitas1903

Board Regular
Joined
Mar 8, 2012
Messages
127
Hey guys,

I tried this but i have to run the macro always when i open the excel.
is this possible to make it steady. I just dont want f1 in my excel life :)
 

Domski

Well-known Member
Joined
Jan 18, 2005
Messages
7,292
Did you put the code in your personal macro workbook as suggested?

Dom
 

Watch MrExcel Video

Forum statistics

Threads
1,118,822
Messages
5,574,520
Members
412,600
Latest member
Andyb2
Top