Try this. Put the code in a sheet module or the ThisWorkbook module and make sure you follow the comment at the top of the code.
Option Explicit
'Needs reference to Microsoft Internet Controls (Tools -> References in VB Editor)
Private WithEvents IE As InternetExplorer
Private Copied As Boolean
Public Sub CopyWebPage()
'Delete all data on active sheet
Cells.Delete Shift:=xlUp
Set IE = CreateObject("InternetExplorer.Application")
Copied = False
With IE
.Visible = True
.Navigate "http://www.google.com"
While .busy Or .ReadyState <> READYSTATE_COMPLETE: DoEvents: Wend
'Wait until the page has been copied by the DocumentComplete event
While Not Copied
DoEvents
Wend
'Now paste it to A1 on the active sheet and quit IE
Range("A1").Select
ActiveSheet.PasteSpecial Format:="Text", Link:=False, DisplayAsIcon:=False
Range("A1").Select
.Quit
End With
Set IE = Nothing
End Sub
Private Sub IE_DocumentComplete(ByVal pDisp As Object, URL As Variant)
'Copy the page to the clipboard
If pDisp = IE Then
IE.ExecWB OLECMDID_SELECTALL, OLECMDEXECOPT_DONTPROMPTUSER
IE.ExecWB OLECMDID_COPY, OLECMDEXECOPT_DODEFAULT
Copied = True
End If
End Sub
Bookmarks