Search code examples
vba

Trigger Keyboard Shortcut with VBA Macro


I want to open osk.exe. My company doesnt allow this by their security standards. But i can open it using a Keyboard-Shortcut. Is there a way to trigger this shortcut using Macros? Like:

If Condition = True Then
    Press "Windows + Ctrl + O"
End If

Or something along the way?


Solution

  • Take a look at the SendKeys statement. https://learn.microsoft.com/en-us/office/vba/language/reference/user-interface-help/sendkeys-statement

    In your case SendKeys "^{O}" will simulate the keystrokes.