Share Pastebin
Guest
Public paste!

zixyer

By: a guest | Dec 9th, 2008 | Syntax: VisualBasic | Size: 0.85 KB | Hits: 98 | Expires: Never
Copy text to clipboard
  1. Sub LoadZips()
  2.     Const ZIP_COLUMN As Integer = 1
  3.     Const OUTPUT_COLUMN As Integer = 2
  4.    
  5.     Dim ie
  6.     Set ie = CreateObject("InternetExplorer.Application")
  7.     ie.Visible = True
  8.    
  9.     ie.Navigate "http://www.zipinfo.com/search/zipcode.htm"
  10.     Do Until ie.ReadyState = 4 ' READYSTATE_COMPLETE
  11.        DoEvents
  12.     Loop
  13.    
  14.     For Each Cell In Selection
  15.         If Not ie.Document.Forms(0).tz.Checked Then
  16.             ie.Document.Forms(0).tz.Click
  17.         End If
  18.         ie.Document.Forms(0).zip.Value = Cells(Cell.Row, ZIP_COLUMN).Value
  19.         ie.Document.Forms(0).Go.Click
  20.         Do Until ie.Document.ReadyState = "complete"
  21.             DoEvents
  22.         Loop
  23.         Set tables = ie.Document.GetElementsByTagName("table")
  24.         Cells(Cell.Row, OUTPUT_COLUMN).Value = tables(3).Rows(1).Cells(3).innerText
  25.     Next Cell
  26. End Sub