Question : Export access query results to excel using vba code

I tried the following code to automate the exporting of a query result in my Access database called "Commit_Export" but the file is not saving in the location... also a camputer can be used by different people so telling the path "C:\Documents and Settings\joe\Desktop" might not always work because joe might not sign in... is there a way to make this flexible based on who signed in or give the use the option to chose where to save the file?
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
Dim stDocName As String
Dim FileName As String
Dim XFile As String
Dim tDate As String
Dim FileDir As String

stDocName = "Commit_Export"
FileName = "Wachovia Data Export"
tDate = Format(Now(), "mm-dd-yy")
FileDir = "C:\Documents and Settings\joe\Desktop"
XFile = FileName & tDate & " .xls"

DoCmd.OpenQuery stDocName, acNormal, acEdit
DoCmd.OutputTo acOutputQuery, "Commit_Export", _
acFormatXLS, XFile, False
DoCmd.Close acQuery, "Commit_Export", acSaveNo

Answer : Export access query results to excel using vba code

Had the same problem with R52 and T40 series. Great for the first 5 years, but 3 died with very similar circumstances. One tech told me it was the board but buy the time I found a replacement board and had it installed, I could probably buy a replacement with warranty, etc. Since it was older, that is what I did. I hope you find a better answere. Thx
Random Solutions  
 
programming4us programming4us