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 cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Macro for redirecting keyboard in Word 1

Status
Not open for further replies.

FH

Mechanical
Joined
Jul 1, 2002
Messages
170
Location
CA
Hi everybody,
Is there any way to change the input character in Word?
I need to redirect the keyboard so that every time I press the 'D' key on keyboard, the 'Shift + X' character typed in Word document.
Any macro?

Any prompt reply would be highly appreciated.
:)
Farzad
 
Use the following to assign key "D" to "Macro2":
Sub Macro1()
CustomizationContext = ActiveDocument
aCode = BuildKeyCode(wdKeyD)
KeyBindings.Add KeyCode:=aCode,_
KeyCategory:=wdKeyCategoryMacro, _
Command:="Macro2"
End Sub

Use the following to type "X" in the document:
Sub Macro2()
Selection.TypeText Text:="X"
End Sub

Run Macro1 once to initialize the KeyBindings. Now everytime you press key "D" it types "X" in the document.

Note that you could store the binding in the normal template by replacing:
CustomizationContext = ActiveDocument
with:
CustomizationContext = NormalTemplate

Paul
 
Dear PaulWeal,
Your answer is perfect.
Thanks a lot.
The macro works as I mentioned, but as I use the arabic fonts, there is some problems to insert arabic characters in VBA editor.
:)
Farzad
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top