1

I am currently using Office 2010, Visual Basic for Applications 7, and Internet Explorer 9.

The current issue I've been having is that using an IE object seems to fail on our intranet, and I was wondering if there was a fix for this.

Functioning code:

Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")
IE.Navigate "http://www.google.com"
WaitUntilReady IE
'Application.Wait (Now + TimeValue("00:00:10"))
'IE.Visible = True
MsgBox (IE.Document.body.innerHTML)

Broken code:

Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")
IE.Navigate "http://intranet/"
WaitUntilReady IE
'Application.Wait (Now + TimeValue("00:00:10"))
'IE.Visible = True
MsgBox (IE.Document.body.innerHTML)

Functioning code does exactly what it should. Makes an IE object which doesn't show up visibly on screen, and returns a message box with the HTML code contents of google.com

Broken code loads our intranet home page, in a VISIBLE IE window, and returns this error:

Run-time error '-2147417848 (80010108)'
Automation error
The object invoked has disconnected from its clients

I've read through Excel VBA Controlling IE local intranet which suggested using an IP address instead of intranet/ which doesn't work because the IP directs to a different splash screen.

I've also tried using

Set IE = New InternetExplorerMedium

But this A- didn't seem to work either, and B- would mean making sure all my fellow employees enable this Reference.

Also, I've tried loading google.com first, then having it navigate to intranet/, which also didn't help.

Anyone have any suggestions? From my understanding, loading intranet/ is causing IE to disconnect from Excel somehow?

2 Answers2

0

SO! After several days of research and at a complete loss for what was going on, I stumbled on to someone talking about intranet compatibility mode in another article.

Force "Internet Explorer 8" browser mode in intranet

Things happened to click in my head when I read this, realizing that if IE loaded in compatibility, it would explain why the Excel VBA macro lost control of IE, as compatibility mode might be loading as a separate instance of IE.

Settings > Internet Options > Security > Local Intranet > Sites >

Disable "Auto detect intranet" and enable "Include all network paths (UNCs)" fixes the error I was having, perfectly.

Community
  • 1
  • 1
0
'simply replace -seem to work
' Set ie = CreateObject("InternetExplorer.Application")
Set ie = New InternetExplorerMedium

another solution

Set IE = CreateObject("InternetExplorer.Application")
IE.Navigate ("http://URLOnMyIntranet/site.html")
IE.Visible = True

Set IE = nothing
Set objShellApp = CreateObject("Shell.Application")
For Each objWindow In objShellApp.Windows
    Debug.Print objWindow.LocationName
     If LCase(objWindow.LocationName) = LCase("Your windows name, use debug to find out") Then
            Set IE = objWindow
     End If
Next`enter code here`

also see this post

Community
  • 1
  • 1
ozmike
  • 2,600
  • 1
  • 27
  • 35
  • Having tried this, it did not work either. I suspect it is caused by the security settings, as I posted below. – Andrew Blackburn Mar 16 '15 at 15:33
  • Hi if Internetexplorermedium dosen't work - did you try 'another solution' part II of answer - this dosen't need any new references. Compiles with VBA and excel references only. Its sneaky cause it looks for a window not an IE session so circumvents the IE issue. Close down all ie session and the use the Debug.Print objWindow.LocationName (window name) in the loop to find the window name. Hope that helps. – ozmike Mar 24 '15 at 06:03