none
Shortcuts RRS feed

  • Question

  • Hi

    I have to work in word document routinely and i have to use one, two , three, four, five (in words)........ for numerals 1, 2, 3, 4, 5 .............. frequently

    i have written macros for this which perform excellently

    example

    Sub MacroOne()
        Selection.TypeText Text:="one "
    End Sub

    now i want to assign a key for example numerical keypad key "1" for the above without using any ctrl or alt i.e. just pressing 1 MacroOne should execute - can anybody help me please

    thanks in advance


    Saturday, April 1, 2017 10:32 AM

Answers

  • It's possible, but I would not recommend it - you wouldn't be able to type numbers any more. For example, if you typed Purushothama2222, it would come out as PurushothamaTwo Two Two Two.

    But if you really want to do it:

    • Activate the Visual Basic Editor (Alt+F11).
    • Activate the Immediate Window (Ctrl+G)
    • Type or copy/paste the following line:

    KeyBindings.Add wdKeyCategoryMacro, "MacroOne", vbKey1

    • With the insertion point anywhere in the line, press Enter.

    To restore the "1" key to its original function, do the same but with the line

    FindKey(vbKey1).Clear


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    Saturday, April 1, 2017 2:21 PM

All replies

  • It's possible, but I would not recommend it - you wouldn't be able to type numbers any more. For example, if you typed Purushothama2222, it would come out as PurushothamaTwo Two Two Two.

    But if you really want to do it:

    • Activate the Visual Basic Editor (Alt+F11).
    • Activate the Immediate Window (Ctrl+G)
    • Type or copy/paste the following line:

    KeyBindings.Add wdKeyCategoryMacro, "MacroOne", vbKey1

    • With the insertion point anywhere in the line, press Enter.

    To restore the "1" key to its original function, do the same but with the line

    FindKey(vbKey1).Clear


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    Saturday, April 1, 2017 2:21 PM
  • It works great, macro is executed when the number keys above the typing area are pressed and the number keypad is working normally, so i can use both as required

    Thank you very much

    Saturday, April 1, 2017 3:40 PM