How do I get a list of the hotkeys I've assigned to Excel VBA macros?

CrazyBritGuy

New Member
Joined
Dec 10, 2019
Messages
13
Office Version
  1. 2016
Platform
  1. Windows
I'm using Excel 2016 on Windows 10.

I've used Macro Options to assign keys:

1576014768352.png


and know I can use "Application.OnKey" to make assignments, but despite many searches, I've been unable to find a way to get a list of what I've assigned using the Macro Options dialogue. I know could do a simple search of the VBA code IF I'd used "Application.OnKey"
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Also :
 
Upvote 0
Try this
VBA Code:
'Excel Options >> Trust Access to the VBA Project Object Model
'   >> References:
'Microsoft Visual Basic for Applications Extensibility
'Microsoft Scripting Runtime
'Microsoft VBScript Regular Expressions 5.5
'-------------------------------------------------------------
Sub List_Macro_Shortcuts()
    Dim vbProj          As VBIDE.VBProject
    Dim vbComp          As VBIDE.VBComponent
    Dim codeMod         As CodeModule
    Dim lineNum         As Long
    Dim procKind        As VBIDE.vbext_ProcKind
    Dim sProcName       As String
    Dim sShortCutKey    As String
    Dim fn              As String
    Dim s               As String
    Dim fso             As FileSystemObject
    Dim ts              As TextStream
    Dim re              As RegExp
    Dim mc              As MatchCollection
    Dim m               As Match
    
    fn = ThisWorkbook.Path & "\Temp.txt"
    Set re = New RegExp

    With re
        .Global = True
        .IgnoreCase = True
        .Pattern = "Attribute\s+(\w+)\.VB_ProcData\.VB_Invoke_Func = ""(\S+)(?=\\)"
    End With

    Set fso = New FileSystemObject
    Set vbProj = ActiveWorkbook.VBProject
    
    For Each vbComp In vbProj.VBComponents
        Select Case vbComp.Type
            Case Is = vbext_ct_StdModule
                vbComp.Export fn
                Set ts = fso.OpenTextFile(fn, ForReading, Format:=TristateFalse)
                s = ts.ReadAll
                ts.Close
                fso.DeleteFile (fn)
                If re.Test(s) = True Then
                    Set mc = re.Execute(s)
                    For Each m In mc
                        Debug.Print vbComp.Name, m.SubMatches(0), m.SubMatches(1)
                    Next m
                End If
        End Select
    Next vbComp
End Sub
 
Upvote 0
I was also searching for a solution for this issue and your macro worked like magic.
Thanks....
 
Upvote 0
I have set the 3 References listed in the comments before the Sub statement.
I have enabled Trust access to the VBA Project Object Model.
But it doesn't show any hotkeys defined for MY macros
 
Upvote 1
Would it be possible to add the words "keyboard shortcut" to the title of this thread so others searching for this will find it? I only found it after another moderator suggested it as I wasn't using the term "hotkeys"

Thread:

Is it possible to list all macro keyboard shortcuts in a workbook?​

 
Upvote 0
I have set the 3 References listed in the comments before the Sub statement.
I have enabled Trust access to the VBA Project Object Model.
But it doesn't show any hotkeys defined for MY macros
I am having the same problem ☹️.
 
Upvote 0

Forum statistics

Threads
1,214,815
Messages
6,121,715
Members
449,049
Latest member
THMarana

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top