How to "clear" all previous ShortcutKey Assignments

D

Dennis

2003/2007

Have a series of Macros to assign different "sets" of ShortcutKey
assignments like:

Sub DT_ApplyShortCuts()
With Application
.MacroOptions macro:="DT_PswdAdd", Description:="Passwords
Add", ShortcutKey:="A"
.MacroOptions macro:="ClearAudit", Description:="Clear Audit
Highlights", ShortcutKey:="C"
.MacroOptions macro:="FM_FilterDiffReport", Description:="FM
Filter the Difference Report", ShortcutKey:="d"
.MacroOptions macro:="ExceptionCells", Description:="Exception
Cells Highlighted", ShortcutKey:="E"
.MacroOptions macro:="FindFormulaCells", Description:="Find
and Highlight Formula Cells", ShortcutKey:="F"
.MacroOptions macro:="ColumnCopy", Description:="Copy/Insert/
Move Constants Input column", ShortcutKey:="h"
.MacroOptions macro:="FM_FilterDirList", Description:="FM
Filter the Directory List", ShortcutKey:="k"
.MacroOptions macro:="FM_CreateDirList", Description:="FM
Create Directory List", ShortcutKey:="i"
.MacroOptions macro:="DT_CopyLegend", Description:="FM Copy
Legend", ShortcutKey:="l"
.MacroOptions macro:="FM_LinkSheetInfo", Description:="FM Link
Sheet Info", ShortcutKey:="L"
.MacroOptions macro:="MapCells", Description:="Map Cells",
ShortcutKey:="M"
.MacroOptions macro:="ScreensClose", Description:="Close
Screens", ShortcutKey:="n"
.MacroOptions macro:="PswdRemove", Description:="Password
Remove", ShortcutKey:="O"
.MacroOptions macro:="DT_FormatSheets", Description:="DT
Format Sheets", ShortcutKey:="P"
.MacroOptions macro:="DT_PswdRemove", Description:="DT
Passwords Remove", ShortcutKey:="Q"
.MacroOptions macro:="ReplaceConstants", Description:="Replace
Constants in Formulas", ShortcutKey:="R"
.MacroOptions macro:="RemoveBorders", Description:="Remove Red
Cell Borders", ShortcutKey:="r"
.MacroOptions macro:="Foot_CrossFoot_Fix", Description:="Foot
and CrossFoot Fix", ShortcutKey:="T"
.MacroOptions macro:="ExtractConstantsInFormulas",
Description:="Extract Constants in Formulas", ShortcutKey:="t"
.MacroOptions macro:="PasswordsAllInternal",
Description:="Clear all Passwords", ShortcutKey:="w"
.MacroOptions macro:="ConsolCells", Description:="Consolidate
Cells", ShortcutKey:="W"
.MacroOptions macro:="Unhide_All", Description:="Unhide All",
ShortcutKey:="X"
.MacroOptions macro:="Screen", Description:="Add Second
Screen", ShortcutKey:="y"
.MacroOptions macro:="UsedRangeReset", Description:="Used
Range Reset", ShortcutKey:="Z"
End With

End Sub

In the ShortCutKey assignment above "k" is assigned to
"FM_FilterDirList" with:
.MacroOptions macro:="FM_FilterDirList", Description:="FM
Filter the Directory List", ShortcutKey:="k"

Via another Macro, I attempted to re-assign "k" to "XLPolySAP" but
the assignment stayed FM_FilterDirList??

BTW, both macros are in the same module but named (and run)
separately.

What is happening, how can I avoid the issue in the future?

TIA Dennis
 
V

Vergel Adriano

Dennis,

Try using the Onkey Method of the application object instead. Search for
"OnKey" in the VBA Help.

For example, to assign CTRL+k to XLPolySAP:

application.OnKey "^k", "XLPolySAP"


To clear the key assignment, you would use:

application.OnKey "^k"
 
V

Vergel Adriano

I forgot to mention that if you do it using the MacroOptions, you need to
keep track of which macro is assigned to which key because you'll need to
unassign it first before assigning it to a different macro.. for example:

With Application
'remove shortcut for FM_FilterDirList
.MacroOptions macro:="FM_FilterDirList", ShortcutKey:=""
'assign CTRL+k to XLPolySAP
.MacroOptions macro:="XLPolySAP", ShortcutKey:="k"
End With
 
D

Dennis

Bingo! That explains it, Thanks


I forgot to mention that if you do it using the MacroOptions, you need to
keep track of which macro is assigned to which key because you'll need to
unassign it first before assigning it to a different macro.. for example:

With Application
'remove shortcut for FM_FilterDirList
.MacroOptions macro:="FM_FilterDirList", ShortcutKey:=""
'assign CTRL+k to XLPolySAP
.MacroOptions macro:="XLPolySAP", ShortcutKey:="k"
End With

--
Hope that helps.

Vergel Adriano












- Show quoted text -
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top