Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

transfer spreadsheet assign filename

Status
Not open for further replies.

ali32j

Technical User
Apr 23, 2007
97
GB
Hi All

I am looking to transfer a query from access to Excel file using VB code. I have the following code

Dim FileName
FileName = [Forms]![aform1]![User]

DoCmd.TransferSpreadsheet acExport, , _
"CustomerDetails", _
FileName, True

but i need to add location information to this, can anyone tell me how to specify the folder to save the file in??

thanks

Ali
 
Something like:
Code:
Dim FileName
FileName = "C:\MyFolder\" & [Forms]![aform1]![User]

DoCmd.TransferSpreadsheet acExport, , _
"CustomerDetails", _
FileName, True
?

Hope this helps

HarleyQuinn
---------------------------------
You can hang outside in the sun all day tossing a ball around, or you can sit at your computer and do something that matters. - Eric Cartman

Get the most out of Tek-Tips, read FAQ222-2244: How to get the best answers before posting.

 
Hi

Appreciate your help but this has saved a file in my documents titled "0.XLS" ...??

Could it be my system causing the problem??

Ali
 
What is in [Forms]![aform1]![User]?

HarleyQuinn
---------------------------------
You can hang outside in the sun all day tossing a ball around, or you can sit at your computer and do something that matters. - Eric Cartman

Get the most out of Tek-Tips, read FAQ222-2244: How to get the best answers before posting.

 
ah ok i needed to put extra \ in, and had slight error, working perfectly now thankyou!

Ali
 
if i wanted to export multiple tables to the same file, do i need repeat the code? or is there an easier way to do this?

Ali
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top