Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cannot assign shortkut key to macros, what's wrong?

Status
Not open for further replies.

Maisie2007

Technical User
Apr 12, 2007
42
CA
Hi,

I'm trying to assign a shortcut key to my macro and it just won't work.
I can't type anything into the "Press new shortcut key" box.
The "Assign" "Remove" and "Reset All" buttons are greyed out.
My "Num Lock" button is off.
I've set the security to low.
I've googled the problem with no success either.
Funny thing is, at school, it will work on their computer, so I'm thinking there's something wrong with my program??

Here's the string:

Sub historyofpresentillness()
'
' historyofpresentillness Macro
' Macro recorded 1/09/09
'
Selection.TypeText Text:="History of present illness:"
End Sub

Anyone know what might be wrong?

Thanks!
 
Ok, I found that pressing the Alt key or Ctrl key first and then something like HP works.

Why do I have to add the Alt or Ctrl key, instead of just pressing the keys I want, like HPI?
 
Because "HPI" is just text. The function keys tell Word to look for a keybinding (something to DO) matching the following keys ("HPI").

You may want to consider (I would) using an AutoText instead for something as simple as that. Or even an AutoCorrect.

If an AutoText: type "hpi" and press F3. "History of present illness:" would be typed into the document.

If an AutoCorrect: set it up as "hpi", and then when you type "hpi" and a space, Word would replace "hpi" with "History of present illness:"

Gerry
 
In other words, no VBA macro is required.

Gerry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top