Page tree

Welcome to FreeSoftwareServers Confluence Wiki

Skip to end of metadata
Go to start of metadata

Make sure to put this inside "ThisWorkbook" NOT a Module!

Sub Workbook_Open()

  With Application
    .OnKey "{F1}", "Your_Macro_Name"
    .OnKey "{F2}", "Your_Macro_Name"
  End With

End Sub

Sub Workbook_BeforeClose(Cancel As Boolean)

  With Application
    .OnKey "{F1}" 'Clears the setting on close
    .OnKey "{F2}"
  End With

End Sub

Note: F# do have functions so better to use CTRL+SHIFT+{LETTER} Eg: Use this Module to test CTRL+SHIFT+S

Public Sub SetKey() 
Application.OnKey "^+S", "Test" 
End Sub

Public Sub Test()
 MsgBox "Testing"
End Sub

This only works for Microsoft Word (I'd Rec using the above code, but I'm posting for reference)

You must go to File >> Options

  • Customize Ribbon >> Keyboard Shortcuts [Customize]
  • Under 'Catagories' select "Macro's"
  • All it will display all Macro's for normal.dotm, but you can change to "ThisDocument" by selecting "Save Changes In"
  • Configure Shortcut and Assign
  • Test and Profit


  • No labels