Where are user keyboard shortcuts stored

nbrcrunch

Well-known Member
Joined
Jan 1, 2003
Messages
2,062
I tried searching this website for "shortcuts file" or "shortcuts storage" and found nothing.

When writing VBA, I would like to specify a shortcut. I've noticed on recorded macros the line that Excel puts in that is just a comment line acknowledging the shortcut exists. But where is this stored? Or at least, how do I create one myself without having to use the Macro menu option?
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Re: Where are user shortcuts stored

maybe i'm just not getting this, but, shortcut to what?
 
Upvote 0
Re: Where are user shortcuts stored

well, don't know where their stored. sorry.

i know macro is Alt+F8, & VB editor is Alt-F11. but you probably knew that.
then there's the macro shortcut keys...

good luck :!:
 
Upvote 0
Perhaps I'm not making myself clear. (Its obvious, given the two replies I've had.) :-?

Create a macro, any macro. Or just go the VBA editor, open a new module and type the following:

Sub hello()
MsgBox ("Hello Word")
End Sub
____________________________

Now, try to assign that to a keyboard shortcut of Ctrl-Shift-S BUT don't assign it using the dialog "Macro Options" dialog box. Can't? Okay, then go ahead and use the "Macro Options" dialog box.

Now, where did that shortcut get stored? I don't know, do you?

Okay, so I've spent the last hour surfing Microsoft's TechNet website for articles on "keyboard accelerator" (the official term) and for "keyboard shortcuts." All to no avail. So lets just say that where ever that shortcut is stored is one of the those hidden dark mysteries. So then, how about this as an alternative question: Can it be done another way?
________________

I prefer not to call it insanity. It's just free-spirited consciousness.
 
Upvote 0
Hi, try this where Macro1 is the name of the macro and you want to assign CTRL-SHIFT-T as the shortcut.

Code:
Application.MacroOptions Macro:="Macro1", Description:= _
        "Macro recorded 23/01/2004 by Dilbert", ShortcutKey:="T"

Believe it or not I used the macro recorder to record the keystrokes and this is what it showed me. Worked OK for me. :-)

Where it actually gets stored I dont know.
 
Upvote 0
Parry,

Thank you, but that line is just a comment line. It doesn't functionally do anything. As a test, remove it and try the shortcut again. It will work since the comment is not a VBA command, function, value or argument.

All comment lines start with the single quote mark ( ' ).

For example, in the following snippet, the Ducks line is a comment
________

Sub QuackUp()
' What do ducks do when they fly upside down? They quack up!
MsgBox("Hello World")
end sub
________

Also, because of a PM I just got:
Please note that my frustration is with myself--not being able to definitively explain what I need. I am not upset with anyone else. I greatly appreciate all the voluntary effort and willing aid each of you have made to reply.
 
Upvote 0
ShortcutKeys are assigned to a Macro by using the MacroOptions method and specifying the name of the Macro and the ShortcutKey as arguments, eg:

Application.MacroOptions Macro:="MyMacro", HasShortcutKey:=True, ShortcutKey:="Z"

That statement (and the one in in Parry's post) is not a comment.

But there does not appear to be a property that returns the ShortcutKey that is assigned to a particular Macro, if that's what you mean. The setting must be held somewhere, but it is not exposed in the object model. Have a look here:

http://216.92.17.166/board2/viewtopic.php?t=25813
 
Upvote 0
If I'm hearing you right, I can't find it either. Not how to assign them but what file they are stored in. I played with your example and searched for files that were updated when I saved the change. Can't find it. Played with renaming the .xlb file but the macro assignment was still there.

Is this the area that your question is in?
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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