Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
In message of Thu, 22 Oct 2009
16:15:23 in microsoft.public.excel.programming, Walter Briscoe writes Journey Planner is a Transport for London facility which calculates a journey for a customer. I use it a lot, both manually and from VBA. Manually, I load <http://journeyplanner.tfl.gov.uk/user/XSLT_TRIP_REQUES T2?language=en&ptOptionsActive=1 and complete a form. The code below calls it from VBA. I have not found out how to cause buttons to be clicked from VBA. Should he be interested in the question, Joel could doubtless answer it. This is code demonstrating where I have got to. As I have not bothered specifying date and time for the journey, the reader's innerhtml will vary slightly from mine. This is my code: [snipped original code] I had a look at the DOM tutorials on <http://w3schools.com and found the children attribute. I applied it with the innerhtml attribute as a probe and managed to get details of one journey. I am confident that a full understanding of how to drive the Journey Planner is only a matter of slogging. ;) This code does the job. There is one long line of about 130 bytes which may wrap. I would normally use _ to split a long line. I could not get that to work. Any suggestions? Option Explicit Sub JPcall() ' ' JPcall Macro ' Click the "View " button of the first row of a journeyplanner table ' Dim IE As Object ' IWebBrowser2 ' SHDocVw.InternetExplorer Dim U As String ' URL apecifying the origin and destination of the Journey Dim Journeys As Object ' DispHTMLElementCollection Dim Journey As Object ' HTMLTable Dim Row0 As Object ' HTMLTableSection Dim Row1 As Object ' HTMLTableRow Dim Row2 As Object ' HTMLTableCell Dim Row3 As Object ' HTMLAnchorElement Set IE = CreateObject("InternetExplorer.Application") IE.Visible = True U = "http://journeyplanner.tfl.gov.uk/user/XSLT_TRIP_REQUEST2?" & _ "language=en&sessionID=0&ptOptionsActive=-1" & _ "&type_origin=stop&name_origin=BANK" & _ "&type_destination=stop&name_destination=ANGEL " IE.Navigate2 U Do While IE.busy Or IE.ReadyState < 4: DoEvents: Loop If 1 = 0 Then IE.document.getElementsByTagname("Table").Item(0). Children.Item(0).Children.Item(1).Children.Item(5) .Children.Item(0).Click Else Set Journeys = IE.document.getElementsByTagname("Table") Set Journey = Journeys.Item(0) Set Row0 = Journey.Children.Item(0) Set Row1 = Row0.Children.Item(1) Set Row2 = Row1.Children.Item(5) Set Row3 = Row2.Children.Item(0) Row3.Click ' Get 1st journey details End If ' Wait until details arrive Do While IE.busy Or IE.ReadyState < 4: DoEvents: Loop ' Detail analysis could be done here End Sub Thanks! -- Walter Briscoe |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Difficulty analysing Journey Planner result | Excel Programming | |||
Analysing my CSV data | Excel Discussion (Misc queries) | |||
analysing companies - help!! | Excel Discussion (Misc queries) | |||
Journey time calculator | Excel Programming | |||
How to audit and edit Excell files on the journey? | Excel Discussion (Misc queries) |