'I would like to go to a website that have iframes, fill out text boxes in the iframe, then click a button in the iframe
'Here is my base code that works for a website that does not have iframes
'1) open a website, fill out the building information, and Click Search
'2) Click all open Violations
'3) Search for apt 2A
'This code works for this example, but what I am trying to figure out is if the elements on page 1,2,3 are in an iFrame, how would the code change?
Public Sub IE_HPD()
'Needs references to Microsoft Internet Controls and Microsoft HTML Object Library
Dim baseURL As String
Dim IE As InternetExplorer
baseURL = "http://www.nyc.gov/html/hpd/html/home/home.shtml"
Set IE = New InternetExplorer
With IE
.Visible = True
'Navigate to the main page
.navigate baseURL
While .Busy Or .readyState <> READYSTATE_COMPLETE: DoEvents: Wend
' On Page 1
.document.getElementById("p1").Value = 2 ' Burough
.document.getElementById("p2").Value = 711 ' Street Number
.document.getElementById("p3").Value = "East 231" ' Address
.document.getElementById("searchbutton").click ' Click button
While .Busy Or .readyState <> READYSTATE_COMPLETE: DoEvents: Wend
' On Page 2, click All Violations Button
.document.parentWindow.execScript "__doPostBack('lbtnAllOpenViol','')"
While .Busy Or .readyState <> READYSTATE_COMPLETE: DoEvents: Wend
'On Page 3 put unit 2A in the text box and click search
.document.getElementById("txtUnitNo").Value = "2A"
.document.getElementById("btnAptSearch").click
End With
Set IE = Nothing
Set shellWins = Nothing
MsgBox ("done")
End Sub
'Here is my base code that works for a website that does not have iframes
'1) open a website, fill out the building information, and Click Search
'2) Click all open Violations
'3) Search for apt 2A
'This code works for this example, but what I am trying to figure out is if the elements on page 1,2,3 are in an iFrame, how would the code change?
Public Sub IE_HPD()
'Needs references to Microsoft Internet Controls and Microsoft HTML Object Library
Dim baseURL As String
Dim IE As InternetExplorer
baseURL = "http://www.nyc.gov/html/hpd/html/home/home.shtml"
Set IE = New InternetExplorer
With IE
.Visible = True
'Navigate to the main page
.navigate baseURL
While .Busy Or .readyState <> READYSTATE_COMPLETE: DoEvents: Wend
' On Page 1
.document.getElementById("p1").Value = 2 ' Burough
.document.getElementById("p2").Value = 711 ' Street Number
.document.getElementById("p3").Value = "East 231" ' Address
.document.getElementById("searchbutton").click ' Click button
While .Busy Or .readyState <> READYSTATE_COMPLETE: DoEvents: Wend
' On Page 2, click All Violations Button
.document.parentWindow.execScript "__doPostBack('lbtnAllOpenViol','')"
While .Busy Or .readyState <> READYSTATE_COMPLETE: DoEvents: Wend
'On Page 3 put unit 2A in the text box and click search
.document.getElementById("txtUnitNo").Value = "2A"
.document.getElementById("btnAptSearch").click
End With
Set IE = Nothing
Set shellWins = Nothing
MsgBox ("done")
End Sub