HI, I'm writing a Macro for Excel to go to a website, (Orbitz.com) enter departure and return dates and locations(this part works fine) then I want to be able to click on the "Get flights" Button and have it retrieve the airfare price. Then just put that price on the spreadsheet. I can put the info into the webpage no problem but I can't figure out how to make it click the "Get Flights" Button. I've done a lot of research on the web to no avail. Any assistance would be appreciated. Below is what I believe to be the pertinent webpage code as well as what I've done so far.
I think part of the problem is that I can't really identify the "Button" in the code.
Thanks Steve
My code:
Sub Test()
Dim ele As Object
Dim DeptDate As String
Dim RetnDate As String
Set objIE = CreateObject("InternetExplorer.Application")
Set ie = CreateObject("InternetExplorer.Application")
'Retreive Departure point from Excel sheet
DeptPoint = Sheets("Sheet1").Range("A1")
'Retreive Departure Date from Excel sheet
DeptDate = Sheets("Sheet1").Range("B1")
'Retreive Arrival point from Excel sheet
RetnPoint = Sheets("Sheet1").Range("A2")
'Retreive Arrival Date from Excel sheet
RetnDate = Sheets("Sheet1").Range("B2")
'Load Orbitz.com
With objIE
.Visible = True
.Navigate "http://www.orbitz.com/flights/"
'Wait till its loaded
Do While .Busy Or .ReadyState <> 4
DoEvents
Loop
'Enter Departure Point in web page
Set DeparturePoint = .document.getElementsByName("ar.rt.leaveSlice.orig.key")
DeparturePoint.Item(0).Value = DeptPoint
'Enter Arrival Point in web page
Set ArrivalPoint = .document.getElementsByName("ar.rt.leaveSlice.dest.key")
ArrivalPoint.Item(0).Value = RetnPoint
'Enter Departure date in web page
Set DepDate = .document.getElementsByName("ar.rt.leaveSlice.date")
DepDate.Item(0).Value = DeptDate
'Enter Return date in Web page
Set ReturnDate = .document.getElementsByName("ar.rt.returnSlice.date")
ReturnDate.Item(0).Value = RetnDate
'Im good down to here.**************************************
'This is where I want to put the button click code
Do While .Busy Or _
.ReadyState <> 4
DoEvents
Loop
'The rest of this needs to be customized to my needs.********************
Set objIE = Nothing
End Sub
Web page code: I think this is the area of concern. But i'm A novice at this.
<div class="group groupWithButtons">
<div class="buttons">
<div class="submit button-primary button-medium" >
<input type="submit" value="Search" name="search" data-agent="{
"type":"Interstitial"
}" data-wt-ti="SearchForm-searchButton" />
I think part of the problem is that I can't really identify the "Button" in the code.
Thanks Steve
My code:
Sub Test()
Dim ele As Object
Dim DeptDate As String
Dim RetnDate As String
Set objIE = CreateObject("InternetExplorer.Application")
Set ie = CreateObject("InternetExplorer.Application")
'Retreive Departure point from Excel sheet
DeptPoint = Sheets("Sheet1").Range("A1")
'Retreive Departure Date from Excel sheet
DeptDate = Sheets("Sheet1").Range("B1")
'Retreive Arrival point from Excel sheet
RetnPoint = Sheets("Sheet1").Range("A2")
'Retreive Arrival Date from Excel sheet
RetnDate = Sheets("Sheet1").Range("B2")
'Load Orbitz.com
With objIE
.Visible = True
.Navigate "http://www.orbitz.com/flights/"
'Wait till its loaded
Do While .Busy Or .ReadyState <> 4
DoEvents
Loop
'Enter Departure Point in web page
Set DeparturePoint = .document.getElementsByName("ar.rt.leaveSlice.orig.key")
DeparturePoint.Item(0).Value = DeptPoint
'Enter Arrival Point in web page
Set ArrivalPoint = .document.getElementsByName("ar.rt.leaveSlice.dest.key")
ArrivalPoint.Item(0).Value = RetnPoint
'Enter Departure date in web page
Set DepDate = .document.getElementsByName("ar.rt.leaveSlice.date")
DepDate.Item(0).Value = DeptDate
'Enter Return date in Web page
Set ReturnDate = .document.getElementsByName("ar.rt.returnSlice.date")
ReturnDate.Item(0).Value = RetnDate
'Im good down to here.**************************************
'This is where I want to put the button click code
Do While .Busy Or _
.ReadyState <> 4
DoEvents
Loop
'The rest of this needs to be customized to my needs.********************
Set objIE = Nothing
End Sub
Web page code: I think this is the area of concern. But i'm A novice at this.
<div class="group groupWithButtons">
<div class="buttons">
<div class="submit button-primary button-medium" >
<input type="submit" value="Search" name="search" data-agent="{
"type":"Interstitial"
}" data-wt-ti="SearchForm-searchButton" />