Exporting query to Temp drive

T

top4747

I am currently exporting my query
with this module:
....
Then
DoCmd.SetWarnings False
DoCmd.OpenQuery "Look-Up by Name", acViewNormal, acEdit
DoCmd.Close acQuery, "Look-Up by Name"
DoCmd.OutputTo acQuery, "Look-Up by Name",
"MicrosoftExcelBiff8(*.xls)", "d:\look-up by name.xls", True, "", 0
End If
....

This saves the query to the users D drive and then asks if you want to
replce that field every time it is exported.
However, i would love to be able to eport to the users 'temp' drive, so

that the excel file is not replaced every time it is exported. Can
anyone help???? Thanks so much!
 
D

Douglas J. Steele

Take a look at http://www.mvps.org/access/api/api0054.htm at "The Access
Web" for how to find out the location of the "special" folders.

Of course, another option would be to delete the file if it already exists.
You'd do that as:

If Len(Dir("d:\look-up by name.xls")) > 0 Then
Kill "d:\look-up by name.xls"
End If
 
B

Bill Mosca

I got this from the AllAPI viewer (http://www.mentalis.org/index2.shtml)

Private Declare Function GetTempPath Lib "kernel32" Alias "GetTempPathA"
(ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long

Public Function FindTempFolder() As String
Dim strTemp As String

strTemp = String(100, Chr$(0))
'Get the temporary path
GetTempPath 100, strTemp
'strip the rest of the buffer
strTemp = Left$(strTemp, InStr(strTemp, Chr$(0)) - 1)
Debug.Print strTemp
FindTempFolder = strTemp


End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top