Try this code. You enter the Zip code and the data gets enetered into the US
government Zip code web page and finds the city.
Sub GetZipCodes()
ZIPCODE = InputBox("Enter 5 digit zipcode : ")
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
URL = "http://zip4.usps.com/zip4/citytown_zip.jsp"
'get web page
IE.Navigate2 URL
Do While IE.readyState < 4
DoEvents
Loop
Do While IE.busy = True
DoEvents
Loop
Set Form = IE.document.getElementsByTagname("Form")
Set zip5 = IE.document.getElementById("zip5")
zip5.Value = ZIPCODE
Form(0).Submit
Do While IE.busy = True
DoEvents
Loop
Set Table = IE.document.getElementsByTagname("Table")
If Table(0).Rows(0).innertext = "" Then
MsgBox ("Invalid Zip code")
Else
Location = Table(0).Rows(2).innertext
End If
IE.Quit
MsgBox ("Zip code = " & ZIPCODE & " City/State = " & Location)
End Sub
" wrote:
I'm a beginner at VB, but know way more than everyone I work with.
I've never tried to call another application with Excel before and am
trying to submit data from a workbook into a form on a web page.
Right now I'm trying to come up with the simplest proof of concept I
can get, so let's assume I'm logged in exactly to the page I need to
be at, all I want to demonstrate is the ability to copy data from the
Workbook to the various fields on the web page.
Anyone feeling like throwing me a bone here?
1) trying to take the value in A2 "account number" field from my excel
sheet and put it in the "account number" field in Explorer
2) tab to the next field in explorer
3) Repeat for 25 or so fields
Anyone have any canned script they might be willing to share?