
'Microsoft VBScript Regular Expressions 5.5ĭim sProcName As String, sShortCutKey As Stringĭim RE As RegExp, MC As MatchCollection, M As Match 'Microsoft Visual Basic for Applications Extensibility 'MUST set to Trust Access to the VBA Project Object Model It will NOT list shortcut keys that were assigned using the Application.OnKey method. If a macro does not have a shortcut key, it will not be listed.ĮDIT The routine only lists those shortcuts that were assigned using the Macro Dialog box on the Excel worksheet. (That could have been done in the macro, but I got lazy). If C:\Temp does not exist, you will have to create it. The exported file is stored in a folder C:\Temp, and the file is deleted when we are done with it. I have just output the results to the Immediate window, but you could do also easily put it on a worksheet. Running the macro below requires that you set the option to Trust access to the VBA Project object model in the Trust Center settings and also that you set references in VBA as listed in the code. I don't know the significance of the \n14 at the end (and I am not sure if it will be consistent as I have not extensively tested this. The bolded information above is the name of a macro, and the associated shortcut key. The line in the exported file that has this information looks like:Īttribute MacroShortCutKeys.VB_ProcData.VB_Invoke_Func = " a\n14" That file can then be parsed to return the procedure name and the associated shortcut key.

It turns out although the shortcut key cannot be accessed "directly", if you export a module, any shortcut key is listed in the exported file. You can list the keys assigned to a macro with a VBA macro.
