View Full Version : Transfer spreadsheet question


fieldling
08-28-2008, 09:04 AM
I use the following code on a command button to save "Table1" as an excel spreadsheet called Table1.xls in a folder called export folder.
Private Sub Command14_Click()
stDocName = "Table1"
DoCmd.TransferSpreadsheet [acExport], , stDocName, _
"C:\Export Folder\Table1.xls", 0

End Sub

This works fine but I would like to save the spreadsheet like this: "Current Date"Table1.xls
So if I did it today it would look something like this "280808Table1.xls"

Any ideas how I can do this?
Thanks

DJkarl
08-28-2008, 09:08 AM
I use the following code on a command button to save "Table1" as an excel spreadsheet called Table1.xls in a folder called export folder.
Private Sub Command14_Click()
stDocName = "Table1"
DoCmd.TransferSpreadsheet [acExport], , stDocName, _
"C:\Export Folder\Table1.xls", 0

End Sub

This works fine but I would like to save the spreadsheet like this: "Current Date"Table1.xls
So if I did it today it would look something like this "280808Table1.xls"

Any ideas how I can do this?
Thanks

Something like this should work I think.


stDocName = "Table1"
DoCmd.TransferSpreadsheet [acExport], , stDocName, _
"C:\Export Folder\" & Format(Date, "ddmmyy") & "Table1.xls", 0

KenHigg
08-28-2008, 09:11 AM
Try this:


Private Sub Command14_Click()

dim strFile as string
strFile = "C:\Export Folder\" & Format(Date, "ddmmyy") & "Table1.xls"

stDocName = "Table1"
DoCmd.TransferSpreadsheet [acExport], , stDocName, _
strFile, 0

End Sub


???

KenHigg
08-28-2008, 09:12 AM
Darn, you beat me to it - :p

fieldling
08-29-2008, 02:32 AM
Thanks guys. I'll try it out and let you know.