ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   QueryTables Add (https://www.excelbanter.com/excel-programming/321173-querytables-add.html)

Marta[_3_]

QueryTables Add
 
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


All times are GMT +1. The time now is 04:32 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com