LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default Unspecified Automation Error

I am trying to develop a VBA function that will do a reverse zip code lookup at
the USPS site. I have a sub that steps through a range of zip codes, and
retrieves the appropriate city or cities in that zip code.

The code works fine initially, but after a while, it returns an error on the

set IE = New InternetExplorer

line. The error is an "Unknown Automation Error" with text:
-2147467259 (80004005) Unspecified error.

Changing to late binding (at least after the error messages start) do not make
a difference.

Closing and re-opening Excel doesn't help.

The only way I can resume normal operations, that I've found so far, is to
reboot my computer.

Excel 2007
XP Pro SP3
IE8

Any help appreciated. There is code that calls this function, but I don't
think it is relevant to the error message.

============================
'*** IMPORTANT NOTE ***
'MUST SET REFERENCE (TOOLS/REFERENCES IN MAIN MENU BAR)
'TO:
' Microsoft Internet Controls
' In Excel 2007, this is called "Microsoft Browser Helpers"
Option Explicit
Private Function RevZip(sZip5 As String) As Variant
Dim IE As InternetExplorer
Const sURL As String = "http://zip4.usps.com/zip4/citytown_zip.jsp"
Dim sHTML As String
Dim sTemp() As String
Dim i As Long

' Group2 = City Group3=State IGNORE CASE
Const rePattern As String = "headers=pre(<b)?([^,]+),\s([^<]+)"
Dim lNumCities As Long

'next line is highlighted when automation error occurs
Set IE = New InternetExplorer
IE.Navigate sURL
IE.Visible = False
Do While IE.ReadyState < READYSTATE_COMPLETE
DoEvents
Loop
Do While IE.Busy = True
DoEvents
Loop

IE.Document.all("zip5").Value = sZip5
IE.Document.all("Submit").Click
Do While IE.ReadyState < READYSTATE_COMPLETE
DoEvents
Loop
Do While IE.Busy = True
DoEvents
Loop
sHTML = IE.Document.body.innerhtml
Set IE = Nothing

lNumCities = RegexCount(sHTML, rePattern)
ReDim sTemp(0 To 1, 0 To lNumCities - 1)
For i = 0 To lNumCities - 1
sTemp(0, i) = RegexMid(sHTML, rePattern, i + 1, 2)
sTemp(1, i) = RegexMid(sHTML, rePattern, i + 1, 3)
Next i
RevZip = sTemp
End Function
==============================

--ron
 
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
"automation error" "unspecified error" ML Purdy Excel Discussion (Misc queries) 5 April 3rd 23 06:49 PM
System Error &H80004005 (-2147467259). Unspecified error Chip Pearson Excel Programming 2 December 31st 06 04:35 PM
Unspecified Automation Error _Yoyo Excel Discussion (Misc queries) 1 May 23rd 05 08:23 PM
Unspecified Automation Error _Yoyo Excel Discussion (Misc queries) 0 May 20th 05 09:16 PM
Unspecified Automation Error _Yoyo Excel Discussion (Misc queries) 0 May 20th 05 02:06 PM


All times are GMT +1. The time now is 10:02 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"