I need to import all the data from a local html file to a spreadsheet. If I do it "manually", I do a Select-All, Copy and then paste in Excel.
I found some code "sub websurf" on a three year old entry that was written to do something like that, but the source file was a website URL.
I tried to use it but did have to comment the .ReadyState segment
then it gave an error on the EXECdb : The Object invoked has disconnected from its clients
It does open the file in a new window
Any advice? Here is the code
-------------------------
Sub websurf()
' Original definition
'Const url As String = "http://web1.ncaa.org/d1mfb/Internet/national%20rankings/IA_teamrush.html"
' new entry referencing my html file
Const url As String = "C:\Quote\Imports\Test.html"
Set ie = CreateObject("internetexplorer.application")
With ie
'you can change any of the below settings to your liking except for the navigate line.
.Top = 1
.Left = 1
.Height = 400
.Width = 500
.AddressBar = False
.MenuBar = False
.Toolbar = False
.Visible = true
.Navigate url
' I eliminated the next do-while
'Do While
.ReadyState <> 4 'this makes excel wait for IE to open the page
'DoEvents
'Loop
' the next 2 lines select and copy the entire contens of the web page to the clipboard.
' This fails ---------------
.ExecWB OLECMDID_SELECTALL, OLECMDEXECOPT_DONTPROMPTUSER
.ExecWB OLECMDID_COPY, OLECMDEXECOPT_DODEFAULT
End With
Activesheet.paste
ie.Quit
End Sub
I found some code "sub websurf" on a three year old entry that was written to do something like that, but the source file was a website URL.
I tried to use it but did have to comment the .ReadyState segment
then it gave an error on the EXECdb : The Object invoked has disconnected from its clients
It does open the file in a new window
Any advice? Here is the code
-------------------------
Sub websurf()
' Original definition
'Const url As String = "http://web1.ncaa.org/d1mfb/Internet/national%20rankings/IA_teamrush.html"
' new entry referencing my html file
Const url As String = "C:\Quote\Imports\Test.html"
Set ie = CreateObject("internetexplorer.application")
With ie
'you can change any of the below settings to your liking except for the navigate line.
.Top = 1
.Left = 1
.Height = 400
.Width = 500
.AddressBar = False
.MenuBar = False
.Toolbar = False
.Visible = true
.Navigate url
' I eliminated the next do-while
'Do While
.ReadyState <> 4 'this makes excel wait for IE to open the page
'DoEvents
'Loop
' the next 2 lines select and copy the entire contens of the web page to the clipboard.
' This fails ---------------
.ExecWB OLECMDID_SELECTALL, OLECMDEXECOPT_DONTPROMPTUSER
.ExecWB OLECMDID_COPY, OLECMDEXECOPT_DODEFAULT
End With
Activesheet.paste
ie.Quit
End Sub