W
Walter Briscoe
I run Excel 2003 SP3 on Windows Vista Business SP2 and IE8.
The code below works in 2 different ways for 2 users on one machine.
I think 'CreateObject("InternetExplorer.Application")' grabs a default
version of the code which maps an HTML page to the Document Object Model
(DOM). My code has inconsistent behavior as a result.
I can fix this. Rather than refer to
IE.Document.ChildNodes.Item(1).ChildNodes.Item(1).ChildNodes.Item(5) ...
Doc.getelementbyid("stations") is fairly close to what I want to read.
OTOH, it seems unhelpful to specify an OLE access object ambiguously.
A couple of months ago, I hit a similar problem and restored IE8 rather
than use IE9.
How do I find and control the version loaded?
'CreateObject("InternetExplorer.Application.1")' does not help.
P.S. The Locals Window seems weakly equipped. I can't use Ctrl+A and
Ctrl+C to put its contents in the clipboard as text. I suppose I could
try Print Screen to take a picture. I want to be able to compare the
different versions. Does anybody know of software which will produce a
structured dump of an arbitrary variable?
' This shows different behavior for 2 versions of "InternetExplorer.Application"
' Both are seen for two users of one Vista machine
' For one version, the following is written to the immediate window and an error is shown
' V = 1 T.Length = 2 TypeName(T.Item(V)) = HTMLHtmlElement
' V = 1 T.Length = 2 TypeName(T.Item(V)) = HTMLBody
' V = 2 T.Length = 12 TypeName(T.Item(V)) = HTMLCommentElement
'
' For the other version, the following is written and the code succeeds:
' V = 1 T.Length = 2 TypeName(T.Item(V)) = HTMLHtmlElement
' V = 1 T.Length = 2 TypeName(T.Item(V)) = HTMLBody
' V = 2 T.Length = 10 TypeName(T.Item(V)) = HTMLDivElement
' V = 5 T.Length = 25 TypeName(T.Item(V)) = HTMLDivElement
' V = 8 T.Length = 13 TypeName(T.Item(V)) = HTMLDivElement
' V = 5 T.Length = 6 TypeName(T.Item(V)) = HTMLUListElement
' V = 0 T.Length = 2 TypeName(T.Item(V)) = HTMLLIElement
' V = 1 T.Length = 2 TypeName(T.Item(V)) = HTMLUListElement
Option Explicit
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) ' Allows URL speed control
#If True Then
Dim IE As Object
#Else
Dim IE As SHDocVw.InternetExplorer ' Needs Tools/References/Microsoft Internet Controls
#End If
Dim Doc As Object ' IE.Document
Public Sub ShowIE()
Dim O As Object
TxURL "http://www.tfl.gov.uk/tfl/livetravelnews/realtime/track.aspx?offset=1"
Set O = GetBranch(Doc, 1, 1, 2, 5, 8, 5, 0, 1)
End Sub
Private Sub TxURL(ByVal URL1 As String)
Set IE = CreateObject("InternetExplorer.Application")
Debug.Assert Not IE Is Nothing
IE.Visible = True
IE.Navigate2 URL1
Wait4IE
Set Doc = IE.document
End Sub
Private Sub Wait4IE()
Do
Sleep 50
DoEvents
Loop While IE.Busy Or IE.ReadyState <> 4 ' READYSTATE_COMPLETE
End Sub
Private Function GetBranch(ByVal O As Object, ParamArray Path() As Variant) As Object
Dim T As Object
Dim V As Variant
Set T = O.childnodes
For Each V In Path
Debug.Print "V = " & V, "T.Length = " & T.Length, _
"TypeName(T.Item(V)) = " & TypeName(T.Item(V))
Set T = T.Item(V).childnodes
Next V
Set GetBranch = T
End Function
The code below works in 2 different ways for 2 users on one machine.
I think 'CreateObject("InternetExplorer.Application")' grabs a default
version of the code which maps an HTML page to the Document Object Model
(DOM). My code has inconsistent behavior as a result.
I can fix this. Rather than refer to
IE.Document.ChildNodes.Item(1).ChildNodes.Item(1).ChildNodes.Item(5) ...
Doc.getelementbyid("stations") is fairly close to what I want to read.
OTOH, it seems unhelpful to specify an OLE access object ambiguously.
A couple of months ago, I hit a similar problem and restored IE8 rather
than use IE9.
How do I find and control the version loaded?
'CreateObject("InternetExplorer.Application.1")' does not help.
P.S. The Locals Window seems weakly equipped. I can't use Ctrl+A and
Ctrl+C to put its contents in the clipboard as text. I suppose I could
try Print Screen to take a picture. I want to be able to compare the
different versions. Does anybody know of software which will produce a
structured dump of an arbitrary variable?
' This shows different behavior for 2 versions of "InternetExplorer.Application"
' Both are seen for two users of one Vista machine
' For one version, the following is written to the immediate window and an error is shown
' V = 1 T.Length = 2 TypeName(T.Item(V)) = HTMLHtmlElement
' V = 1 T.Length = 2 TypeName(T.Item(V)) = HTMLBody
' V = 2 T.Length = 12 TypeName(T.Item(V)) = HTMLCommentElement
'
' For the other version, the following is written and the code succeeds:
' V = 1 T.Length = 2 TypeName(T.Item(V)) = HTMLHtmlElement
' V = 1 T.Length = 2 TypeName(T.Item(V)) = HTMLBody
' V = 2 T.Length = 10 TypeName(T.Item(V)) = HTMLDivElement
' V = 5 T.Length = 25 TypeName(T.Item(V)) = HTMLDivElement
' V = 8 T.Length = 13 TypeName(T.Item(V)) = HTMLDivElement
' V = 5 T.Length = 6 TypeName(T.Item(V)) = HTMLUListElement
' V = 0 T.Length = 2 TypeName(T.Item(V)) = HTMLLIElement
' V = 1 T.Length = 2 TypeName(T.Item(V)) = HTMLUListElement
Option Explicit
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) ' Allows URL speed control
#If True Then
Dim IE As Object
#Else
Dim IE As SHDocVw.InternetExplorer ' Needs Tools/References/Microsoft Internet Controls
#End If
Dim Doc As Object ' IE.Document
Public Sub ShowIE()
Dim O As Object
TxURL "http://www.tfl.gov.uk/tfl/livetravelnews/realtime/track.aspx?offset=1"
Set O = GetBranch(Doc, 1, 1, 2, 5, 8, 5, 0, 1)
End Sub
Private Sub TxURL(ByVal URL1 As String)
Set IE = CreateObject("InternetExplorer.Application")
Debug.Assert Not IE Is Nothing
IE.Visible = True
IE.Navigate2 URL1
Wait4IE
Set Doc = IE.document
End Sub
Private Sub Wait4IE()
Do
Sleep 50
DoEvents
Loop While IE.Busy Or IE.ReadyState <> 4 ' READYSTATE_COMPLETE
End Sub
Private Function GetBranch(ByVal O As Object, ParamArray Path() As Variant) As Object
Dim T As Object
Dim V As Variant
Set T = O.childnodes
For Each V In Path
Debug.Print "V = " & V, "T.Length = " & T.Length, _
"TypeName(T.Item(V)) = " & TypeName(T.Item(V))
Set T = T.Item(V).childnodes
Next V
Set GetBranch = T
End Function