I think you're already achieving this.
To get the ODBC QueryTable error:
For i = 1 To Application.ODBCErrors.Count
msg = msg & Application.ODBCErrors(1).ErrorString
Next
There is the equivalent for OLEDB QueryTables: Application.OLEDBErrors
--
Rob van Gelder -
http://www.vangelder.co.nz/excel
"T. Erkson" wrote in message
...
How do I intercept query table errors, bypassing the Excel ones?
Here's an example of what I'm trying to do using examples from the Help
files:
Sub Macro2()
Workbooks(1).Activate
Application.DisplayAlerts = False ' This doesn't make a difference for
my
purposes
On Error GoTo ErrorHandler
Selection.QueryTable.Refresh BackgroundQuery:=False
GoTo Exit_Sub
ErrorHandler:
Msg = "Error # " & Str(Err.Number) & " was generated by " & Err.Source &
Chr(13) & Err.Description
MsgBox Msg, , "Error", Err.HelpFile, Err.HelpContext
Exit_Sub:
On Error Resume Next
Application.DisplayAlerts = True
End Sub
For testing I've moved the database to a different folder so the first
error
window is "Please Enter MS JET OLE DB Initialization Information", then my
example message box. I want to COMPLETELY bypass the Windows error window
and just use mine.
Suggestions?