View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
MacroChaotic MacroChaotic is offline
external usenet poster
 
Posts: 3
Default Invoke €śQuery Wizard€ť programmatically from automation or VSTO

Have you tried recording a macro?

Sub mcrDemoSQL()
'
' mcrDemoSQL Macro
' Macro recorded 11/1/2004 by MacroChaotic'
'
With ActiveSheet.QueryTables.Add(Array(Connection:=("OD BC;DRIVER=SQL
Server;SERVER=yourmomma;UID=yourdaddy;DATABASE=you rdata;Trusted_Connection=Yes"), Destination:=Range("A1"))
.CommandText = Array("SELECT getdate()")
.Name = "Sample Query"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.Refresh BackgroundQuery:=False
End With
End Sub


" wrote:

Is there anyway to dynamically invoke €śQuery Wizard€ť or €śMicrosoft Query€ť
programmatically from automation or VSTO?

The €śQuery Wizard€ť is the one that comes up in the menu: Data\Import
External Data\New Database Query

I need this to build SQL statement to import data from a SQL server.

Any help with this is greatly appreciated.

Regards,

GoldTree