![]() |
How can I run a query(dqy file) from an Excel macro
I have queries stored in -- \Application Data\Microsoft\Queries. I'd like to
run them from an Excel macro. Does anyone know how to code? thanks, Bill B |
How can I run a query(dqy file) from an Excel macro
I ran a macro and modified it a little.
'/=================================================/ Sub Macro1() Dim strConnection As String Dim strFullFileName As String, strFolder As String Dim strQueryName As String strQueryName = "DeleteMe" strFolder = "D:\Temp\" strFullFileName = _ strFolder & strQueryName & ".dqy" strConnection = "FINDER;" & strFullFileName With ActiveSheet.QueryTables.Add( _ Connection:=strConnection, _ Destination:=Range("A1")) .Name = strQueryName .FieldNames = True .RowNumbers = False .FillAdjacentFormulas = False .PreserveFormatting = True .RefreshOnFileOpen = False .BackgroundQuery = True .RefreshStyle = xlInsertDeleteCells .SavePassword = True .SaveData = True .AdjustColumnWidth = True .RefreshPeriod = 0 .PreserveColumnInfo = True .Refresh BackgroundQuery:=False End With End Sub '/=================================================/ HTH, Gary Brown "Bill B" wrote: I have queries stored in -- \Application Data\Microsoft\Queries. I'd like to run them from an Excel macro. Does anyone know how to code? thanks, Bill B |
All times are GMT +1. The time now is 06:51 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com