View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Sharad Naik Sharad Naik is offline
external usenet poster
 
Posts: 212
Default Selection.QueryTable problem

Selection.QueryTable will give that error.
This is not proper way to refer to a QueryTable.
You can do, for example:

With ActiveSheet.QueryTables(1)
'if 1 is the correct index of the required querytable.
'else replace 1 with the correct index.

Sharad
"JenC" wrote in message
...
Hi,

I am trying to use the following in an excel (2003) spread sheet:

With Selection.QueryTable
.Connection=
"ODBC;DSN=Live;UID=admin;;SERVER=LIVE;DBNAME=DATA; LUID=admin;"
.CommandText = strSelectStatement
.Refresh BackgroundQuery:=False
End With

and I keep getting :

Error Number: 1004
Error Description: Application-defined or object-defined error

I have had a quick look at the help files and online and have tried a
number
of alternatives but with no success.

Any help/tips greatly appreciated.

Thanks,
J