Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Word 2007: How do I programmatically assign a shortcut to a vba procedure

Posted on 2009-02-11
2
Medium Priority
?
999 Views
Last Modified: 2013-11-25
I have a Hello World procedure stored in a particular word 2007 (macro enabled) document that I use a lot:
Sub HelloWorld()
MsgBox "Hello World"
End Sub

How can I programmatically (using vba) assign a shortcut of:
Alt + q or Alt + Shift + q
to this procedure?
Thank you!

p.s. if not possible, any alternatives?
0
Comment
Question by:PioneerSolutions
2 Comments
 
LVL 22

Expert Comment

by:Flyster
ID: 23617182
Go to the Office button and select Word Options - Customize. At the bottom of that screen is Keyboard Options. Select Customize. In the categories box select Macros. Click in the Press new shortcut key box and then press the hotkeys you want, i.e. ctrl+shift+8.

Flyster
0
 
LVL 4

Accepted Solution

by:
Ledigimate earned 1000 total points
ID: 23621555
Flyster clearly didn't understand the question.

Attached is the VBA code for assigning the key combination [Alt + Q] to the procedure named HelloWorld.

Note: The HelloWorld procedure must be stored in the document, not in a module.
CustomizationContext = ThisDocument
KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyAlt, wdKeyW), _
KeyCategory:=wdKeyCategoryMacro, Command:="HelloWorld"

Open in new window

0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft has changed the look and feel of Azure AD and Microsoft account sign-in pages so that you will have a more unified look and feel when moving between the two interfaces.
I came across an unsolved Outlook issue and here is my solution.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question