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
error.
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.visua lbasic.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.Excepti on' occurred in
microsoft.visua lbasic.dll
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.Applicat ion")
myActive = myExcel.ActiveS heet
s = CType(myActive. Name, String)
Console.WriteLi ne("Excel: " + s)
' Block 2, Create Internet Explorer object and navigate
Dim myIE As New SHDocVw.Interne tExplorerClass
s = ""
myIE = CType(CreateObj ect("InternetEx plorer.Applicat ion"),
SHDocVw.Interne tExplorer)
myIE.Visible = True
myIE.Navigate2( "www.yahoo.com" )
While myIE.ReadyState <> SHDocVw.tagREAD YSTATE.READYSTA TE_COMPLETE
End While
s = CType(myIE.Name , String)
Console.WriteLi ne("myIE.Name = " + s)
Dim myIEDoc As mshtml.IHTMLDoc ument2
myIEDoc = CType(myIE.Docu ment, mshtml.IHTMLDoc ument2)
Console.WriteLi ne("myIEDoc.ur l = " + myIEDoc.url)
' Block 3, try to point to the running Internet Explorer
Dim myIE2 As SHDocVw.Interne tExplorerClass
s = ""
Try
myIE2 = CType(GetObject (, "InternetExplor er.Application" ),
SHDocVw.Interne tExplorer)
myIE2.Visible = True
myIE2.Navigate2 ("www.microsoft .com")
Catch ex As Exception
While True
Console.WriteLi ne("Exception Message: " + ex.Message)
Console.WriteLi ne()
If ex.InnerExcepti on Is Nothing Then
Exit While
Else
ex = ex.InnerExcepti on
End If
End While
End Try
If myIE2 Is Nothing Then Exit Sub
While myIE2.ReadyStat e <> SHDocVw.tagREAD YSTATE.READYSTA TE_COMPLETE
End While
s = CType(myIE2.Nam e, String)
Console.WriteLi ne("myIE2.Name = " + s)
Dim myIEDoc2 As mshtml.IHTMLDoc ument2
myIEDoc2 = CType(myIE.Docu ment, mshtml.IHTMLDoc ument2)
Console.WriteLi ne("myIEDoc2.ur l = " + myIEDoc2.url)
End Sub
End Class
--
Software developer/Tester