Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 236
Default 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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
another macro query - deleting a worksheet within a query DavidHawes Excel Discussion (Misc queries) 2 February 26th 07 10:05 AM
Need to Query Excel File Opened by Another User Paul Excel Discussion (Misc queries) 0 December 13th 06 05:57 PM
Excel data query locks source file jim.bahr Excel Discussion (Misc queries) 0 June 10th 05 05:48 AM
VB Code or Excel macro to run Query/Import on Access file Harry[_8_] Excel Programming 13 February 22nd 05 07:27 PM
Excel query in a macro Stacie[_2_] Excel Programming 0 January 14th 04 09:44 PM


All times are GMT +1. The time now is 01:27 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"