1
Sub Extractdatafromwebsite()
Dim ie As InternetExplorer
Dim Eventno As String
Dim doc As HTMLDocument
Eventno = Sheet1.Range("A2").Value


ie.Visible = True
ie.navigate "https://www.bankeauctions.com/#" & Eventno

Do
    DoEvents
    Loop Until ie.readyState = READYSTATE_COMPLETE

Set doc = ie.document
On Error Resume Next
output = doc.getElementById("ContentPlaceHolder1_lblReserverPrice" & Eventno).innerText
Sheet1.Range("B2").Value = output

ie.Quit

enter image description here

Community
  • 1
  • 1
  • You might want to read [this](http://stackoverflow.com/questions/33677107/excel-vba-difference-between-declaring-a-generic-object-versus-specifying-objec)? – findwindow Nov 12 '15 at 19:24

2 Answers2

2

You haven't actually created an instance of IE yet, so there's nothing to make visible

Dim IE As InternetExplorer

Set IE = New InternetExplorer '// <~~ The bit you need

IE.Visible = True

...

When you Dimension a variable, you are simply reserving some memory in order to place something there. Data types (such as Integer or String) do not need to be Set - but Internet Explorer is an Object

An Object needs to be built and in order to do that, the system needs some instructions - a blueprint if you will - of how to build that object. This is called a Class.

You have asked the system to reserve some memory for your IE object, but until you actually create the object and place it in that memory, there is nothing to interact with and so you receive that error.

Hope that makes sense.

SierraOscar
  • 17,507
  • 6
  • 40
  • 68
0

You have declared a variable using Dim but you have not initiated an instance. It's like when you're having a baby. You can name it before it's born but you can't really call it (as you call anyone) with its name until it's born (initiated).

Sub Main()

Dim Mike As baby
Set Mike = new baby
Mike.PeekaBoo
'baby laughs
End Sub

Sub Main()
Dim Mike As baby
Mike.PeekaBoo
'Returns an error as an instance of the baby class is not found
End Sub
Amen Jlili
  • 1,884
  • 4
  • 28
  • 51