QueryTables Add

M

Marta

I have a problem, I try the next code:

Dim SQLString As String
SQLString is a Select...

With ActiveSheet.QueryTables.Add(Connection:= _
"ODBC;DRIVER=SQL
Server;SERVER=MAQUETA;UID=marta;PWD=;APP=Microsoft®
Query;WSID=MARTA;DATABASE=CONFIGURACION " _
, Destination:=Range("A9"))
.CommandText = SQLString
.Name = "Consulta desde SQLConfiguracion"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = False
.RefreshStyle = xlOverwriteCells
.SavePassword = True
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = False
.Refresh
End With



If I execute step by step this code, I obtain result about the query,
but if I execute normaly, I don`t obtain data. Please Could somebody
help me?

Thanks in advance
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top