save tables the current directory


I want to record the result of a request and to  save it like a excel file.
Hence I use that function:
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel97, "ShowList_Request", "list.xls"

But it saved it in c:\Data. I would like to save it in the current directory, or in the proper one, (correct workspace of the user whatever the computer used).
Could you help me?
Thank you in advance!
Who is Participating?
Rahul GadeSr. ArchitectCommented:

You may want to try out with, you will probably need to add some safty mechanism to this string operations.

Dim strPath As String
strPath = Left(CurrentDb.Name, InStrRev(CurrentDb.Name, "\"))
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12, "ShowList_Request", strPath + "list.xls"

NoeroAuthor Commented:
Thank you Rahul, great clue!
In the DoCmd commamd you can provide entire path instead of 'list.xls' like "d:\myFolder\link.xls"
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.