PGSystemTester

Force Keystrokes In VBA

Sep 6th, 2017
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'VBA keystroke commands
  2.  
  3. 'I post all of my code for free and am not seeking any financial compensation. If you're
  4. 'compelled to be generous or find this helpful, please consider a tax deductible
  5. 'donation to Reason Magazine: https://reason.com/donatenow/donate.php
  6. 'Share a screenshot with me of your donation, even if just a few bucks.
  7. 'It inspires me to post more of these. My username is PGCodeRider on most social media.
  8.  
  9. 'all below syntax options leverage the application.sendkeys command.
  10. 'So if you wanted to simulate the keystroke of UP and then DOWN here is the code:
  11. Application.SendKeys ("{UP}")
  12. Application.SendKeys ("{DOWN}")
  13.  
  14. '-------
  15. BACKSPACE   {BACKSPACE}, {BS}, or {BKSP}
  16. BREAK   {BREAK}
  17. CAPS LOCK   {CAPSLOCK}
  18. DEL or DELETE   {DELETE} or {DEL}
  19. DOWN ARROW  {DOWN}
  20. END {END}
  21. ENTER   {ENTER}or ~
  22. ESC {ESC}
  23. HELP    {HELP}
  24. HOME    {HOME}
  25. INS or INSERT   {INSERT} or {INS}
  26. LEFT ARROW  {LEFT}
  27. NUM LOCK    {NUMLOCK}
  28. PAGE DOWN   {PGDN}
  29. PAGE UP {PGUP}
  30. PRINT SCREEN    {PRTSC} (reserved for future use)
  31. RIGHT ARROW {RIGHT}
  32. SCROLL LOCK {SCROLLLOCK}
  33. TAB {TAB}
  34. UP ARROW    {UP}
  35. F1  {F1}
  36. F2  {F2}
  37. F3  {F3}
  38. F4  {F4}
  39. F5  {F5}
  40. F6  {F6}
  41. F7  {F7}
  42. F8  {F8}
  43. F9  {F9}
  44. F10 {F10}
  45. F11 {F11}
  46. F12 {F12}
  47. F13 {F13}
  48. F14 {F14}
  49. F15 {F15}
  50. F16 {F16}
  51. Keypad add  {ADD}
  52. Keypad subtract {SUBTRACT}
  53. Keypad multiply {MULTIPLY}
  54. Keypad divide   {DIVIDE}
Add Comment
Please, Sign In to add comment