My code is very simple, but cannot get rid of this error. I tried to assign lines to a variable and then assign it, remove protection from the worksheet and put the code in a new subfunction. The error occurs in the second sub Analyze().
Enum READYSTATE
READYSTATE_UNINTIALIZED = 0
READYSTATE_LOADING = 1
READYSTATE_LOADED = 2
READYSTATE_INTERACTIVE = 3
READYSTATE_COMPLETE = 4
End Enum
Dim html As HTMLDocument
Sub Testing()
Dim ie As InternetExplorer
Set ie = New InternetExplorer
ie.Visible = True
ie.navigate "http://www.realclearpolitics.com/epolls/latest_polls/elections/"
Do While ie.READYSTATE <> READYSTATE_COMPLETE
Application.StatusBar = "Trying to reach RealClearPolitics.com"
DoEvents
Loop
Set html = ie.document
MsgBox html.DocumentElement.outerHTML
Set ie = Nothing
Application.StatusBar = " "
Call Analyze
End Sub
Sub Analyze()
Dim polldate As String
polldate = "date"
Worksheets("Sheet1").Activate
Cells.Clear
Worksheets("Sheet1").Cells(0, 0).Value = "Date"
Worksheets("Sheet1").Cells(0, 1).Value = "Poll"
Worksheets("Sheet1").Cells(0, 2).Value = "Page"
End Sub
source
share