VBA Error:  The object invoked has disconnected from its clients

Problem:

Debug when trying to automate internet explorer.  Getting error message “The object invoked has disconnected from its clients” when trying to access internet explorer web browser through VBA.  Occurs when Excel is disconnected from the referenced instance of Internet Explorer.

Error message:

VBA Internet explorer automation error:  Run-time error ‘-2147417848(80010108’); Automation error.  The object invoked has disconnected from its clients

Solution:

1st Solution you can try setting the internet explorer options as:

 Set ie = CreateObject("InternetExplorer.Application")

	or try

 Dim ie As SHDocVw.InternetExplorer
 Set ie = New InternetExplorerMedium
      
        or try

 Set ie = GetObject("new:{D5E8041D-920F-45e9-B8FB-B1DEB82C6E5E}")

2nd Solution:  Try adding one of these wait loops after you set your IE object or anytime the IE page changes/refreshes.

Set ie = CreateObject("InternetExplorer.Application")
 Do While ie.readyState <> READYSTATE_COMPLETE
 DoEvents
 Loop

While ie.busy
 DoEvents
 Wend

Do While IE.ReadyState = 4: DoEvents: Loop
Do Until IE.ReadyState = 4: DoEvents: Loop

3rd Solution – Change IE Security settings

Object invoked can disconnect from IE client based on IE security zone settings. 
Go to Tools-> IE options -> Advanced tab -> Security section - disable "enable enhanced protected mode".

4th Solution to associate disconnected object with the correct instance of Internet Explorer

Set objShell = CreateObject("Shell.Application")
  my_url = ""
  my_title = ""
IE_Count = objshell.Windows.Count
for x = 1 to (IE_count - 1)   
   on error resume next   
   my_url = objShell.Windows(x).document.Location   
   my_title = objShell.Windows(x).document.Title  
   if my_url like "vba-market.com" then    
      set objIE = objShell.Windows(x)    
      Exit For  
   else  
   End if
Next x
On error goto 0