Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default Web Query (Java Page)

I would like to be able to do zip code lookups from within Excel 2007. I would
like to be able to input a list of zip codes into a column, and have Excel go
to the Internet to find matching cities.

A source for this information http://zip4.usps.com/zip4/citytown_zip.jsp but I
have not found documentation to set up an Excel Web Query to obtain information
from this sort of page.

Is it possible, and is there documentation on the Internet, for accomplishing
this?

Thanks.
--ron
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Web Query (Java Page)

You can use the Internet Explorer Application to get the City Name. I only
got the First City Name but this can be modified to get all the names.

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

Set ZipCodebutton = Form(0).onsubmit

Form(0).Submit
Do While IE.busy = True
DoEvents
Loop

Set Table = IE.document.getElementsByTagname("Table")
Location = Table(0).Rows(2).innertext
IE.Quit
MsgBox ("Zip code = " & ZIPCODE & " City/State = " & Location)


End Sub


"Ron Rosenfeld" wrote:

I would like to be able to do zip code lookups from within Excel 2007. I would
like to be able to input a list of zip codes into a column, and have Excel go
to the Internet to find matching cities.

A source for this information http://zip4.usps.com/zip4/citytown_zip.jsp but I
have not found documentation to set up an Excel Web Query to obtain information
from this sort of page.

Is it possible, and is there documentation on the Internet, for accomplishing
this?

Thanks.
--ron

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default Web Query (Java Page)

On Mon, 3 Nov 2008 19:12:01 -0800, Joel wrote:

You can use the Internet Explorer Application to get the City Name. I only
got the First City Name but this can be modified to get all the names.

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

Set ZipCodebutton = Form(0).onsubmit

Form(0).Submit
Do While IE.busy = True
DoEvents
Loop

Set Table = IE.document.getElementsByTagname("Table")
Location = Table(0).Rows(2).innertext
IE.Quit
MsgBox ("Zip code = " & ZIPCODE & " City/State = " & Location)


End Sub




Thank you very much, Joel.

I will give that a try.

--ron
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default Web Query (Java Page)

On Mon, 3 Nov 2008 19:12:01 -0800, Joel wrote:

You can use the Internet Explorer Application to get the City Name. I only
got the First City Name but this can be modified to get all the names.


Great, Joel. I've got it working selecting the zip codes from a list on a
worksheet, and writing the city name into the adjacent column.

Now all I need to do is work out the issue of invalid zip codes, and I'll be
set.

Thank you very much for your suggestions.
--ron
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Web Query (Java Page)

I made a small change to get the invalid zip codes

"Ron Rosenfeld" wrote:

On Mon, 3 Nov 2008 19:12:01 -0800, Joel wrote:

You can use the Internet Explorer Application to get the City Name. I only
got the First City Name but this can be modified to get all the names.


Great, Joel. I've got it working selecting the zip codes from a list on a
worksheet, and writing the city name into the adjacent column.

Now all I need to do is work out the issue of invalid zip codes, and I'll be
set.

Thank you very much for your suggestions.
--ron



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Inverse result

Can this code be made to return the zip code from a row of three columns that provide the Address, City and State to return a zip code?

On Monday, November 03, 2008 4:01 PM Ron Rosenfeld wrote:


I would like to be able to do zip code lookups from within Excel 2007. I would
like to be able to input a list of zip codes into a column, and have Excel go
to the Internet to find matching cities.

A source for this information http://zip4.usps.com/zip4/citytown_zip.jsp but I
have not found documentation to set up an Excel Web Query to obtain information
from this sort of page.

Is it possible, and is there documentation on the Internet, for accomplishing
this?

Thanks.
--ron



On Monday, November 03, 2008 10:12 PM Joe wrote:


You can use the Internet Explorer Application to get the City Name. I only
got the First City Name but this can be modified to get all the names.

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

Set ZipCodebutton = Form(0).onsubmit

Form(0).Submit
Do While IE.busy = True
DoEvents
Loop

Set Table = IE.document.getElementsByTagname("Table")
Location = Table(0).Rows(2).innertext
IE.Quit
MsgBox ("Zip code = " & ZIPCODE & " City/State = " & Location)


End Sub


"Ron Rosenfeld" wrote:



On Tuesday, November 04, 2008 6:37 AM Ron Rosenfeld wrote:


Thank you very much, Joel.

I will give that a try.

--ron



On Tuesday, November 04, 2008 8:04 PM Ron Rosenfeld wrote:


On Mon, 3 Nov 2008 19:12:01 -0800, Joel wrote:


Great, Joel. I've got it working selecting the zip codes from a list on a
worksheet, and writing the city name into the adjacent column.

Now all I need to do is work out the issue of invalid zip codes, and I'll be
set.

Thank you very much for your suggestions.
--ron



On Wednesday, November 05, 2008 9:56 AM Joe wrote:


I made a small change to get the invalid zip codes

"Ron Rosenfeld" wrote:



Submitted via EggHeadCafe - Software Developer Portal of Choice
Book Review: Excel 2010 - The Missing Manual [OReilly]
http://www.eggheadcafe.com/tutorials...l-oreilly.aspx

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel Web Query for Java Applet driven data website mingInv Excel Discussion (Misc queries) 1 August 25th 10 06:14 AM
using excel to query asp page Lilivati Excel Programming 2 July 3rd 06 09:02 PM
Cant query a web page Gary Excel Programming 5 April 14th 06 02:41 PM
page setup query hsg Excel Discussion (Misc queries) 0 March 17th 06 07:28 PM
Web query & Passwords & Java & HTML claytorm[_11_] Excel Programming 0 August 23rd 04 01:55 PM


All times are GMT +1. The time now is 02:15 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"