Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-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
Jul 1, 2002
170
0
0
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
 
Replies continue below

Recommended for you

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.
Back
Top