I am attempting to set up some IE automation; however, I am running into an error where it states that the object is not supported. Here is where the code is throwing an error
I might be calling the wrong element. The a title="byaddress"
Here is my entire code:
Code:
.document.GetElementsByName("byaddress").Click
I might be calling the wrong element. The a title="byaddress"
Here is my entire code:
Code:
Sub USPS()
Dim eRow As Long
Dim ele As Object
'Dim IE As New InternetExplorer
Sheets("Address Verification").Select
eRow = Sheet1.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
Set objie = CreateObject("InternetExplorer.Application")
For r = 5 To 9
myaddress = Cells(r, 2).Value
mycity = Cells(r, 3).Value
mystate = Cells(r, 4).Value
myzipcode = Cells(r, 5).Value
'myaddress = Range("a2").Value
'mycity = Range("c2").Value
'mystate = Range("d2").Value
'myzipcode = Range("e2").Value
With objie
.Visible = True
.navigate "https://tools.usps.com/go/ZipLookupAction!input.action"
Do While .Busy Or _
.readyState <> 4
DoEvents
Loop
Set what = .document.getElementsByName("tAddress")
what.Item(0).Value = myaddress
Set ZipCode = .document.getElementsByName("tCity")
ZipCode.Item(0).Value = mycity
Set zipcode1 = .document.getElementsByName("tState")
zipcode1.Item(0).Value = mystate
Set zipcode2 = .document.getElementsByName("tZip-byaddress")
zipcode2.Item(0).Value = myzipcode
.document.getElementsByName("byaddress").Click
Do While .Busy Or _
.readyState <> 4
DoEvents
Loop
For Each ele In .document.all
Select Case ele.className
Case "address1 range"
Worksheets("Address Verification").Cells(r, 7).Value = ele.innerText
Case "city range"
Worksheets("Address Verification").Cells(r, 8).Value = ele.innerText
Case "state range"
Worksheets("Address Verification").Cells(r, 9).Value = ele.innerText
Case "zip"
Worksheets("Address Verification").Cells(r, 10).Value = ele.innerText
Case "zip4"
Worksheets("Address Verification").Cells(r, 11).Value = ele.innerText
End Select
'
Next ele
End With
Next r
Set objie = Nothing
Set ele = Nothing
Set IE = Nothing
'IE.Quit
End Sub
Last edited by a moderator: