W
Walter Briscoe
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:
Sub JPcall()
'
' JPcall Macro
' Display the HTML for the first row of a journeyplanner table
'
Dim IE As Object ' IWebBrowser2 ' SHDocVw.InternetExplorer
Dim U As String
Dim Doc As Object ' Object HTMLDocument
Dim Tables As Object ' DispHTMLElementCollection
Dim Tbl As Object
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_destination=stop&name_destination=ANGEL" & _
"&type_origin=stop&name_origin=BANK"
IE.Navigate2 U
Do While IE.busy Or IE.ReadyState <> 4
DoEvents
Loop
Set Doc = IE.document
Set Tables = Doc.getElementsByTagname("Table")
Set Tbl = Tables.Item(0)
MsgBox "htmltext = """ & Tbl.innerhtml & """"
'
End Sub
That grabs a particular row and is the sort of thing which contains the
specification of a button I might want to "click".
?Tbl.innerhtml
<TBODY>
<TR>
<TH>Route</TH>
<TH>Depart</TH>
<TH>Arrive</TH>
<TH>Duration</TH>
<TH>Interchanges</TH>
<TH class=viewheader>View</TH></TR>
<TR>
<TD class=option>1</TD>
<TD class=depart>16:00</TD>
<TD class=arrive>16:08</TD>
<TD class=duration>00:08</TD>
<TD class=interchanges><IMG hspace=1 alt=Tube src="assets/images/icon-tube.gif"></TD>
<TD><A class=jpbutton title="View the details for this route" href="XSLT_TRIP_REQUEST2?language=en&sessionID=JP10_2227696266&requestID=1
&tripSelector1=1&itdLPxx_view=detail&tripSelection=on&command=nop&calculateDistance=1">View</A> <INPUT CHECKED type=checkbox
name=tripSelector1 lf="forms[1].tripSelector1"></TD></TR></TBODY>
I am sorry about the long lines - this is the same thing with wrapping:
?Tbl.innerhtml
<TBODY>
<TR>
<TH>Route</TH>
<TH>Depart</TH>
<TH>Arrive</TH>
<TH>Duration</TH>
<TH>Interchanges</TH>
<TH class=viewheader>View</TH></TR>
<TR>
<TD class=option>1</TD>
<TD class=depart>16:00</TD>
<TD class=arrive>16:08</TD>
<TD class=duration>00:08</TD>
<TD class=interchanges><IMG hspace=1 alt=Tube src="assets/images/icon-
tube.gif"></TD>
<TD><A class=jpbutton title="View the details for this route" href="XSLT
_TRIP_REQUEST2?language=en&sessionID=JP10_2227696266&requestID=1
&tripSelector1=1&itdLPxx_view=detail&tripSelection=on&co
mmand=nop&calculateDistance=1">View</A> <INPUT CHECKED type=checkbox
name=tripSelector1 lf="forms[1].tripSelector1"></TD></TR></TBODY>
Thanks!
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:
Sub JPcall()
'
' JPcall Macro
' Display the HTML for the first row of a journeyplanner table
'
Dim IE As Object ' IWebBrowser2 ' SHDocVw.InternetExplorer
Dim U As String
Dim Doc As Object ' Object HTMLDocument
Dim Tables As Object ' DispHTMLElementCollection
Dim Tbl As Object
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_destination=stop&name_destination=ANGEL" & _
"&type_origin=stop&name_origin=BANK"
IE.Navigate2 U
Do While IE.busy Or IE.ReadyState <> 4
DoEvents
Loop
Set Doc = IE.document
Set Tables = Doc.getElementsByTagname("Table")
Set Tbl = Tables.Item(0)
MsgBox "htmltext = """ & Tbl.innerhtml & """"
'
End Sub
That grabs a particular row and is the sort of thing which contains the
specification of a button I might want to "click".
?Tbl.innerhtml
<TBODY>
<TR>
<TH>Route</TH>
<TH>Depart</TH>
<TH>Arrive</TH>
<TH>Duration</TH>
<TH>Interchanges</TH>
<TH class=viewheader>View</TH></TR>
<TR>
<TD class=option>1</TD>
<TD class=depart>16:00</TD>
<TD class=arrive>16:08</TD>
<TD class=duration>00:08</TD>
<TD class=interchanges><IMG hspace=1 alt=Tube src="assets/images/icon-tube.gif"></TD>
<TD><A class=jpbutton title="View the details for this route" href="XSLT_TRIP_REQUEST2?language=en&sessionID=JP10_2227696266&requestID=1
&tripSelector1=1&itdLPxx_view=detail&tripSelection=on&command=nop&calculateDistance=1">View</A> <INPUT CHECKED type=checkbox
name=tripSelector1 lf="forms[1].tripSelector1"></TD></TR></TBODY>
I am sorry about the long lines - this is the same thing with wrapping:
?Tbl.innerhtml
<TBODY>
<TR>
<TH>Route</TH>
<TH>Depart</TH>
<TH>Arrive</TH>
<TH>Duration</TH>
<TH>Interchanges</TH>
<TH class=viewheader>View</TH></TR>
<TR>
<TD class=option>1</TD>
<TD class=depart>16:00</TD>
<TD class=arrive>16:08</TD>
<TD class=duration>00:08</TD>
<TD class=interchanges><IMG hspace=1 alt=Tube src="assets/images/icon-
tube.gif"></TD>
<TD><A class=jpbutton title="View the details for this route" href="XSLT
_TRIP_REQUEST2?language=en&sessionID=JP10_2227696266&requestID=1
&tripSelector1=1&itdLPxx_view=detail&tripSelection=on&co
mmand=nop&calculateDistance=1">View</A> <INPUT CHECKED type=checkbox
name=tripSelector1 lf="forms[1].tripSelector1"></TD></TR></TBODY>
Thanks!