High Plains Grifter
Board Regular
- Joined
- Mar 9, 2010
- Messages
- 129
heloo people - I need to copy seeral thousand records from a windows programme into excel. Unfortunately, the program does not allow me to select all of the records at once, only one row at a time. However, I can select the top row, copy the contents with Ctrl+c, move down a row with the down arrow, then alt tab back to excel and paste the information into an appropriate cell.
I figured that I could shorten this process by making a little macro which would use the (I'll admit slighty grotty) Application.Sendkeys to do the work for me:
For some reason, Excel does not like the PasteSpecial bit of the macro. Any ideas why?
Any help gratefully received
ps. I made sure that the correct programme was "behind" Excel, and even repeated the experiment with another instance of Excel behind, but the error was the same: Run-time error '1004': Application-defined or object-defined error.
I figured that I could shorten this process by making a little macro which would use the (I'll admit slighty grotty) Application.Sendkeys to do the work for me:
Code:
Sub copyfrom()
Dim i As Integer
Dim rng As Range
i = 1
Do
Set rng = Range("A1").Cells(i, 1)
Application.SendKeys ("%{TAB}")
Application.SendKeys ("^c")
Application.SendKeys ("{DOWN}")
Application.SendKeys ("%{TAB}")
rng.Select
Selection.PasteSpecial Format:="HTML", Link:=False, DisplayAsIcon:=False, NoHTMLFormatting:=True
i = i + 1
Loop Until ActiveCell.IsEmpty = True
End Sub
For some reason, Excel does not like the PasteSpecial bit of the macro. Any ideas why?
Any help gratefully received
ps. I made sure that the correct programme was "behind" Excel, and even repeated the experiment with another instance of Excel behind, but the error was the same: Run-time error '1004': Application-defined or object-defined error.