1

I have managed to get my code to work, but only by searching the internet and finding something that worked, I don't actually understand why.

Could someone please explain why when I used

Dim IE As New InternetExplorer

trying to press a button gave me the error

Object invoked has disconnected from clients

but using

Dim ie As SHDocVw.InternetExplorer

has worked?

Thank You

braX
  • 10,905
  • 5
  • 18
  • 32
Mike Hill
  • 103
  • 2
  • 12

1 Answers1

1

You are trying to do early binding of IE in VBA. Thus, you need to do it like this:

Dim ie As SHDocVw.InternetExplorer or Dim IE As New InternetExplorer, after adding the "Microsoft Internet Controls" library to the project (c:\windows\syswow64\ieframe.dll).

In general, if you want to do late binding, you should do it like this:

Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")

What is the difference between Early and Late Binding? and my understanding about late and early binding

Vityata
  • 41,328
  • 7
  • 50
  • 86