Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Declare Function SetForegroundWindow Lib "user32" (ByVal HWnd As Long) As Long
Sub Button1_Click()
i = 1
Do Until IsEmpty(Cells(i, 1))
HWnd = FindWindow(vbNullString, "Microsoft Excel - Book1")
If HWnd Then
SetForegroundWindow HWnd
Worksheets(1).Range(Cells(i, 1), Cells(i + 2, 2)).Copy
End If
HWnd = FindWindow(vbNullString, "Untitled - Notepad")
If HWnd Then
SetForegroundWindow HWnd
SendKeys "^v"
End If
i = i + 3
Loop
End Sub
Hi all,
I am not sure why the macro does not work properly. I mean, it sometimes copies files as expected, but usually not. Would you advise on that since I have no idea what the culprit is? The aim is to copy data from excel (as a range, 2x3) and paste it into either notepad or other programme.
Bookmarks