Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 279
Default CreateObject Software Versions

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

--
Walter Briscoe
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with CreateObject Q[_4_] Excel Programming 5 August 31st 07 02:19 AM
Createobject for FTP AG Excel Programming 2 June 28th 07 03:49 AM
Please include fonts from previous versions ('98) in new versions JJBQ Excel Discussion (Misc queries) 3 October 8th 05 07:19 PM
CREATEOBJECT Using VB Karthik[_2_] Excel Programming 2 June 16th 04 09:08 PM
REPOST: Software recommendation (Recording software) BruceJ[_2_] Excel Programming 1 November 7th 03 12:52 AM


All times are GMT +1. The time now is 04:44 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"