469,907 Members | 2,170 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,907 developers. It's quick & easy.

GetObject(,"InternetExplorer.Application") unhandled exception

Trying to automate processing 80,000 data sets through 15 web pages.
Application URL creates a new IE instance in which runs first a login form
and then runs the rest of the pages in the new window.

I can connect to a running Excel instance and obtain information from the
Excel DOM. I cannot do the same with Internet Explorer. However, I can
successfully create an new IE instance and manipulate it. Using an
application that has its own VB derived scripting language I get a similar

Sample VB.NET code showing ability to connect running Excel instance,
Creating an IE instance and then failing to connect to the instance is pasted
below. No try/Catch block indicates the problem is in
microsoft.visualbasic.dll. Any ideas or work arounds? VB prefered but I am
comfortable with C# and have used many other languages.

=== Output From Code as pasted ====
Excel: Renamed Sheet1
myIE.Name = Microsoft Internet Explorer
myIEDoc.url = http://www.yahoo.com/
Exception Message: Cannot create ActiveX component.

=== Output From code with no Try/Catch block ====
Excel: Renamed Sheet1
myIE.Name = Microsoft Internet Explorer
myIEDoc.url = http://www.yahoo.com/

An unhandled exception of type 'System.Exception' occurred in

Additional information: Cannot create ActiveX component.

=== Sample Code =====
Public Class MyExplorer
Public Shared Sub main()

' Block 1, pick up running Excel
Dim myExcel As Object
Dim myActive As Object
Dim s As String
myExcel = GetObject(, "Excel.Application")
myActive = myExcel.ActiveSheet
s = CType(myActive.Name, String)
Console.WriteLine("Excel: " + s)

' Block 2, Create Internet Explorer object and navigate
Dim myIE As New SHDocVw.InternetExplorerClass
s = ""
myIE = CType(CreateObject("InternetExplorer.Application") ,
myIE.Visible = True

End While

s = CType(myIE.Name, String)
Console.WriteLine("myIE.Name = " + s)

Dim myIEDoc As mshtml.IHTMLDocument2
myIEDoc = CType(myIE.Document, mshtml.IHTMLDocument2)
Console.WriteLine("myIEDoc.url = " + myIEDoc.url)

' Block 3, try to point to the running Internet Explorer
Dim myIE2 As SHDocVw.InternetExplorerClass
s = ""
myIE2 = CType(GetObject(, "InternetExplorer.Application"),
myIE2.Visible = True

Catch ex As Exception
While True
Console.WriteLine("Exception Message: " + ex.Message)
If ex.InnerException Is Nothing Then
Exit While
ex = ex.InnerException
End If
End While
End Try

If myIE2 Is Nothing Then Exit Sub

End While

s = CType(myIE2.Name, String)
Console.WriteLine("myIE2.Name = " + s)

Dim myIEDoc2 As mshtml.IHTMLDocument2
myIEDoc2 = CType(myIE.Document, mshtml.IHTMLDocument2)
Console.WriteLine("myIEDoc2.url = " + myIEDoc2.url)

End Sub
End Class

Software developer/Tester
Nov 21 '05 #1
0 9757

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Wimpie van Lingen | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.