none
How to get a reminder when "Insert" key is presed RRS feed

  • Question

  • Hi everyone,

    The "Insert" key in my Word is assigned to control the overtype mode. 

    I find I constantly press "Insert" by accident so the typing mode is changed to overtype. Many times, I notice it only after texts being replaced. 

    This is annoying, but I don't want to disable the "Insert" key either, for I could use it in the future.

    So I want to know the macro codes to detect the press of "Insert" key. Then I can choose to turn off the overtype mode before everything is too late. 

    Please help me!!!

    Regards,

    VC


    • Edited by CNL777 Tuesday, March 21, 2017 9:50 AM
    Tuesday, March 21, 2017 9:49 AM

Answers

  • Hi VC77,

    you can try to refer code below.

    Code for Module1:

    Sub AddKeyBinding() 
        With Application 
             ' \\ Do customization in THIS document
            .CustomizationContext = ThisDocument 
             
             ' \\ Add keybinding to this document Shorcut: Alt+0
            .KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyAlt, wdKey0), _ 
            KeyCategory:=wdKeyCategoryCommand, _ 
            Command:="TestKeybinding" 
        End With 
    End Sub 
    

    Code for Module:

    Option Explicit 
     
     ' \\ Test sub for keybinding
    Sub TestKeybinding() 
        MsgBox "We have a winner", vbInformation, "Succes" 
    End Sub 
    

    Reference:

    Add Keybinding to document to launch Macro

    KeyBindings.Key Method (Word)

    Refer link below to get the list of key codes.

    BuildKeyCode Method

    you just need to replace the desire key and try to run the module 1.

    then after when you press that key , it will run the code and display the message from module 2.

    you can also keep all the code in module1, you can modify it as per your requirement.

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, March 22, 2017 2:34 AM
    Moderator

All replies

  • Hi VC77,

    you can try to refer code below.

    Code for Module1:

    Sub AddKeyBinding() 
        With Application 
             ' \\ Do customization in THIS document
            .CustomizationContext = ThisDocument 
             
             ' \\ Add keybinding to this document Shorcut: Alt+0
            .KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyAlt, wdKey0), _ 
            KeyCategory:=wdKeyCategoryCommand, _ 
            Command:="TestKeybinding" 
        End With 
    End Sub 
    

    Code for Module:

    Option Explicit 
     
     ' \\ Test sub for keybinding
    Sub TestKeybinding() 
        MsgBox "We have a winner", vbInformation, "Succes" 
    End Sub 
    

    Reference:

    Add Keybinding to document to launch Macro

    KeyBindings.Key Method (Word)

    Refer link below to get the list of key codes.

    BuildKeyCode Method

    you just need to replace the desire key and try to run the module 1.

    then after when you press that key , it will run the code and display the message from module 2.

    you can also keep all the code in module1, you can modify it as per your requirement.

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, March 22, 2017 2:34 AM
    Moderator
  • Hi Deepak,

    Thanks a million. This is exactly what I need.

    And thank you for the references. I will read them and study the Method.

    Have a good day!

    Regards,

    VC

    Wednesday, March 22, 2017 3:13 AM