Hi
I have a list of Hyperlinks in Column A. These are for a horse racing information website. I usually open each page individually and then copy and paste that information into Excel, which can be labourous at times. I found some code below and added some Sendkey lines to automate this procedure, however it is not working 100% all the time. Sometimes it won't copy the information, even though I put some "wait" time in there. Does anyone know by looking at the code where I am going wrong?
As an example I have listed just 3 hyperlinks: -
Sub Grab_Webpage()
Dim Cell As range
Dim r As Integer
On Error Resume Next
'Last used row in column A
r = range("A50").End(xlUp).row
For Each Cell In range("A1:A" & r) 'Range containing hyperlinks
Cell.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=False
Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=False
Application.CutCopyMode = True
Application.Wait (Now + TimeSerial(0, 0, 3)) 'Wait for webpage to open
' Sendkeys to copy all information on webpage
SendKeys "%{E}"
SendKeys "{A}"
SendKeys "%{E}"
SendKeys "{C}"
SendKeys "%{F4}"
Application.Wait (Now + TimeSerial(0, 0, 3)) 'Wait
' Paste information into Excel
ActiveSheet.PasteSpecial Format:="HTML", Link:=False, DisplayAsIcon:= _
False, NoHTMLFormatting:=True
' Offset cell select ready for next import
ActiveCell.Offset(30, 0).Select
' Cancel previous cached information in Clipboard
Application.CommandBars("Office Clipboard").Visible = False
Application.CutCopyMode = False
Next Cell
End Sub
Regards, Paul
Bookmarks