Assigning a multiple letter shortcut key to a macro in word 2007

A

a_ryan1972

I have a few shortcuts saved which are:

ctrl + shift + T
ctrl + shift + H

I would like to save the following shortcut keys:

ctrl + shift + TH
ctrl + shift + TTH
ctrl + shift + HTH

When I try to assign ctrl + shift + TH, it tells me it is already assigned
to the macro I used ctrl + shift + T for.

Please help.
 
D

Doug Robbins - Word MVP on news.microsoft.com

You could have a macro that you call with Ctrl + Shift + T display an
InputBox into which you would enter the balance of the shortcut key and then
depending upon what is entered, you could have the appropriate macro run

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 
A

a_ryan1972

I'm really not that advanced with macros. I know how to record and use
simple macros, but I do not know how to use the input box with it. Would you
be able to give me the steps or point me in the direction where I can find
them? Thank you.
 
D

Doug Robbins - Word MVP on news.microsoft.com

You would do it like this

Sub T()
Dim MacroName As String
SendKeys "{Right}"
MacroName = InputBox("Enter the balance of the macro name that you want to
run", "Run Macro", "T")
Select Case MacroName
Case "T"
GoTo MacroT
Case "TH"
Call TH
Exit Sub
Case "TTH"
Call TTH
Exit Sub
Case Else
Exit Sub
End Select
MacroT:
MsgBox "You are running Macro T."
End Sub
Sub TH()
MsgBox "You are running Macro TH"
End Sub
Sub TTH()
MsgBox "You are running Macro TTH"
End Sub

Replace the MsgBox statements with the codes from the macros to which you
have assigned those shortcut names and assign your shortcut ctrl + shift + T
to the first of the above three macros. Add additional cases as required,
but all of the macro names that you want to run by this method must start
with T

See the article "What do I do with macros sent to me by other newsgroup
readers to help me out?" at:

http://www.word.mvps.org/FAQs/MacrosVBA/CreateAMacro.htm


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 

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