[Solved] VBA : Paste into Notepad

  • Does anyone know of a way to copy cells out of Excel and paste into Notepad using VBA? I can get notepad open, but I can't get the information to paste into Notepad.


    Any help would be appreciated.

  • Hi Tim


    Try the following code:


    Code
    Sub test()
        'The range that contains the values
        Range("A1:B4").Copy
        'Start Notepad and let it recieve focus
        Shell "notepad.exe", vbNormalFocus
        'Send the keys CTRL+V to Notepad (i.e the window that has focus)
        SendKeys "^V"
    End Sub
  • I couldn't get it to work when I stepped through it, but as soon as I just tried running the macro it work perfectly. Thank you so much you just saved me the biggest headache.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!