View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Stratos Malasiotis Stratos Malasiotis is offline
external usenet poster
 
Posts: 1
Default identifying shortcut keys associated with custom macros

windsurferLA wrote in message ...
In Excel95 or Excel97 is there a way to obtain a list of all the
keyboard shortcuts that have been assigned to custom macros?

I have an Excel based application that has over a 100 macros, many of
which are associated with keyboard shortcuts. Unfortunately, as this
tool has been developed over the years, I have not kept track of which
keys were assigned to which macros. I note that when I hit a certain
key board combination by accident, the program executes a macro. I want
to find out which macro is being executed without having to investigate
each of the macros individually.


Hi,
Just a couple of ideas. I do not know if they apply to Excel 95/97.

If you 'export' the modules that contain the macros you sould get text
documents like:
=================================================
Attribute VB_Name = "Module1"
Sub Macro1()
Attribute Macro1.VB_Description = "Macro recorded 04/02/2004 by
Stratos"
Attribute Macro1.VB_ProcData.VB_Invoke_Func = "g\n14"
' Keyboard Shortcut: Ctrl+g
ActiveCell.FormulaR1C1 = "My name is Stratos."
End Sub
Sub Macro2()
Attribute Macro2.VB_Description = "Macro recorded 04/02/2004 by
Stratos"
Attribute Macro2.VB_ProcData.VB_Invoke_Func = "D\n14"
'
' Keyboard Shortcut: Ctrl+Shift+D
'
ActiveCell.FormulaR1C1 = "I do not remenber much."
End Sub
==================================================

I am not sure what you can do with that, but you could possibly:
- find (if exists) a VBE object that allow access to the
Macro1.VB_ProcData.VB_Invoke_Func attribute (Excel VBE should maintain
it somewhere in its object model)
- loop through the module (macro by macro - VBE API allows it, if I
remember correctly) and parse the text in it.
- parse the exported text file and extract the 'Keyboard Shortcut'
value or the 'VB_ProcData.VB_Invoke_Func attribute' value
- do it manually

Similarly you could loop through all code (using the VBE API) and
automatically write code in each macro to 'print' somewhere (msgbox,
statusbar) etc. the name of the executed macro.

I hope this helps.
If I have misunderstood your query please ignore this post.

Best wishes,
Stratos