0

I have a basic VBA script that opens an InternetExplorer window so a user can authorize an OAuth2.0 connection. As part of this process, their browser is redirected to a callback address containing an access token. At present, I have the redirect URL set to http://localhost.

The script runs properly on Windows 10 with MS Access 2010 and Internet Explorer 11. However, in MS Access 2016 on another Win 10 PC, I receive the error -2147023179 Automation error The interface is unknown.. I have confirmed that the redirect URL is correct and I have also hard coded a resolvable redirect URL which also works.

It appears that when InternetExplorer encounters an unresolvable URL it breaks the VBA connection to the IE instance. I'm looking for info that will help me circumvent this issue.

The code below is what I'm using:

Dim IE as InternetExplorer

' create IE instance
Set IE = CreateObject("InternetExplorer.Application")

Dim url as String: url = "www.some-website.com"

' show IE
IE.Visible = True

' navigate to OAuth authorize URl
IE.Navigate url

' wait for page to load
Do While IE.ReadyState = 4: DoEvents: Loop

' loop until callback url in address bar
' ERROR HAPPENS HERE
While InStr(1, IE.LocationURL, "http://localhost") <= 0
    DoEvents
Wend
BankBuilder
  • 466
  • 2
  • 10

1 Answers1

1

Please try to use InternetExplorerMedium object instead of InternetExplorer object. More detail information, you could check the following links:

Excel VBA Controlling IE local intranet

When using the InternetExplorerMedium object, you might need to add the reference to Microsoft Internet Controls, you could check this link:

How to add VBA References – Internet Controls, HTML Object Library

Zhi Lv
  • 18,845
  • 1
  • 19
  • 30
  • Thanks for your answer. In my case I had to use `InternetExplorerMedium` and loop through the open windows using the shell trick in your first link. – BankBuilder Jan 09 '20 at 14:07