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
  • 11,506
  • 5
  • 20
  • 33
Mike Hill
  • 113
  • 1
  • 2
  • 13

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
  • 42,633
  • 8
  • 55
  • 100