#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default sql

How can I put an sql statment in excel VBA.
Any example will be appreciated.
Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default sql

With ThisWorkbook.Worksheets("Estimate").QueryTables.Ad d
(Connection:= _
"ODBC;DRIVER=SQL
Server;SERVER=servername;UID=yourloginid;APP=Micro soft®
Query;WSID=servername;DATABASE=yourdatabasename;Tr usted_Con
nection=Yes" _
, Destination:=ThisWorkbook.Worksheets
("Estimate").Range("c7"))
.CommandText = Array( _
"SELECT * FROM Quote")
.Name = "Can be any name"
.FieldNames = False
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlOverwriteCells
.SavePassword = True
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.Refresh BackgroundQuery:=False
End With
-----Original Message-----
How can I put an sql statment in excel VBA.
Any example will be appreciated.
Thanks
.

Reply
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



All times are GMT +1. The time now is 09:21 PM.

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"