Wednesday, December 10, 2025

How to copy and paste in notepad excel with Arrow VBA

 Sub CommandButton1_Click()


    Shell "Notepad.exe", vbNormalFocus


    Dim I As Integer


    SendKeys "one"


    SendKeys "{Enter}"

     Application.Wait (Now + TimeValue("00:00:01"))

    SendKeys "^a"

     Application.Wait (Now + TimeValue("00:00:01"))

     SendKeys "^c"

     Application.Wait (Now + TimeValue("00:00:01"))

    SendKeys "{right}"

 Application.Wait (Now + TimeValue("00:00:01"))

    SendKeys "two"

 Application.Wait (Now + TimeValue("00:00:01"))

End Sub


or without interval of time


 Sub CommandButton1_Click()

   Shell "Notepad.exe", vbNormalFocus

Application.Wait (Now + TimeValue("00:00:03"))

    Dim I As Integer

 Dim z As Integer

For z = 1 To 50

    SendKeys "one"

    SendKeys "{Enter}"

    SendKeys "^a"

   SendKeys "^c"

    SendKeys "{right}"

    SendKeys "two"

  Next z

End Sub



No comments:

Post a Comment