0

I've been trying to make a macro that pauses and waits until a key is pressed to resume. In multiple examples online I found this kind of function but when trying it myself, even testing it with the exact same code from the example, I get an error saying that only comments can be placed outside of Sub...End Sub despite the function being made inside.

Sub WaitUntilF9Key()


Private Declare PtrSafe Function GetAsyncKeyState Lib "User32" _
    (ByVal vKey As Long) As Integer


Private Const VK_F9 = &H78

Do Until GetAsyncKeyState(VK_F9)
    DoEvents
Loop

MsgBox "Hello World"
End Sub
braX
  • 11,506
  • 5
  • 20
  • 33

0 Answers0