ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Invoke €śQuery Wizard€ť programmatically from automation or VSTO (https://www.excelbanter.com/excel-programming/313589-invoke-%E2%80%9Cquery-wizard%E2%80%9D-programmatically-automation-vsto.html)

[email protected]

Invoke €śQuery Wizard€ť programmatically from automation or VSTO
 
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

MacroChaotic

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


[email protected]

Invoke €śQuery Wizard€ť programmatically from automation or VSTO
 
Thanks for the relply.

But I am looking for ways to show the "Query Wizard" programmatically from
Automation or VSTO.

Thanks,

"

"MacroChaotic" wrote:

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


James

Invoke €śQuery Wizard€ť programmatically from automation or VSTO
 
I'm trying to do this as well.
the help in MS Query recommend to use DDE. But since DDE is technology used
in VB 3 and VB4, can't really find any reference how to do it.

u can click on help in the MS Query and there is a section on DDE.

rgrds,
James


" wrote:

Thanks for the relply.

But I am looking for ways to show the "Query Wizard" programmatically from
Automation or VSTO.

Thanks,

"

"MacroChaotic" wrote:

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



All times are GMT +1. The time now is 09:15 AM.

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