Results 1 to 7 of 7

Thread: onclick in MS word?

  1. #1

    Thread Starter
    Addicted Member thirith's Avatar
    Join Date
    Oct 2004
    Posts
    196

    onclick in MS word?

    Hi all,

    do you know any funciton in Ms word for key press?

    Regards,
    thirith.

  2. #2
    Lively Member JustinLabenne's Avatar
    Join Date
    Jul 2005
    Location
    Ohio
    Posts
    64

    Re: onclick in MS word?

    Without api, the unreliable SendKeys Method:

    VB Code:
    1. Option Explicit
    2.  
    3. Sub SendKeysMethod()
    4.  
    5.     SendKeys "H", True
    6.     SendKeys "E", True
    7.     SendKeys "L", True
    8.     SendKeys "L", True
    9.     SendKeys "O", True
    10.  
    11. End Sub
    Justin Labenne
    www.jlxl.net

  3. #3

    Thread Starter
    Addicted Member thirith's Avatar
    Join Date
    Oct 2004
    Posts
    196

    Re: onclick in MS word?

    Quote Originally Posted by JustinLabenne
    Without api, the unreliable SendKeys Method:

    VB Code:
    1. Option Explicit
    2.  
    3. Sub SendKeysMethod()
    4.  
    5.     SendKeys "H", True
    6.     SendKeys "E", True
    7.     SendKeys "L", True
    8.     SendKeys "L", True
    9.     SendKeys "O", True
    10.  
    11. End Sub
    thanks,

    i mean when user type any text in the word document.
    can we get the character of press in the documents?

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: onclick in MS word?

    With the API it is either SendMessage, PostMessage, or Keybd_event APIs.

    If you want to simulate a keypress you can also just use the TypeText method.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: onclick in MS word?

    Oh, ok. Then you can create an event and trap for any changes or do a keyboard hook but it would only have to be hooking while word is the active app.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  6. #6

    Thread Starter
    Addicted Member thirith's Avatar
    Join Date
    Oct 2004
    Posts
    196

    Re: onclick in MS word?

    Quote Originally Posted by RobDog888
    Oh, ok. Then you can create an event and trap for any changes or do a keyboard hook but it would only have to be hooking while word is the active app.
    Could you please give me some example code for me?

  7. #7
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: onclick in MS word?

    I dont think I can give an example because its a bit involved and I am talking in logic only.

    GetAsyncKeyState API will do a global hook on the keyboard. For each keypress you would need to get the actie application and see if its word, but then they could be pressing a shortcut key sequence like for saving copy/paste that might not result in a document change.

    What exactly are you trying to do as there may be a better solution to this.?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width