save tables the current directory

Hello!

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!
NoeroAsked:
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"

-Rahul
0
 
NoeroAuthor Commented:
Thank you Rahul, great clue!
0
 
rajvihariCommented:
In the DoCmd commamd you can provide entire path instead of 'list.xls' like "d:\myFolder\link.xls"
0
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.