Exporting CSV File in format "FilenameYYYYMMDD"

  • Thread starter Thread starter David
  • Start date Start date
D

David

I need to export a table in CSV format with the name in format
"FilenameYYYYMMDD"- to a particular drive Do you have VB code to do this?

Also I i seen some formats requiring a "Specification" in the code- The only
way I know to get this is to export the table to excel - change to CSV then
re import - I presume there is a better way?
 
Use TransferText to export directly to a .csv file.

For the FileName argument, you can use an expression similar to this:

"C:\MyFolder\Filename" & Format(Date(), "yyyymmdd") & ".csv"
 
ken,

I tried that using
Action: Transfer Text
Transfer Type: Export delimited
Spec name; blank
Table name :Table123 (name of table)
"C:\MyFolder\Filename" & Format(Date(), "yyyymmdd") & ".csv"
Has Field name: yes
HTML table name: Blank
Code Page: Blank


it just says that C:\MyFolder is not a vaild path- but is there- exports
fine if I use filename.csv
Any idea where I'm going wrong?



Thanks for that I use
 
ken,

I tried that using
Action: Transfer Text
Transfer Type: Export delimited
Spec name; blank
Table name :Table123 (name of table)
"C:\MyFolder\Filename" & Format(Date(), "yyyymmdd") & ".csv"
Has Field name: yes
HTML table name: Blank
Code Page: Blank


it just says that C:\MyFolder is not a vaild path- but is there- exports
fine if I use filename.csv
Any idea where I'm going wrong?

I'd suggest wrapping the entire path/filename in quotemarks. This will be
essential if any folder or file naem contains a blank. The filename argument
should be constructed using code like

Dim strFilename As String
strFilename = """C:\MyFolder\Filename" & Format(Date(), "yyyymmdd") & ".csv"""

Note the triple-doublequotes at the start and end.
 
MyFolder must be an existing folder on your C drive. I used a generic name
"MyFolder" to be a placeholder for your real folder path.
 
Ken,

I had set up a "myfolder" folder- as I said the export works fine without
the date bit at the end but not with it- it says c:/myfolder is not valid.
Any idea where to change the formula?

Cheers
--
Thanks for your help


Ken Snell said:
MyFolder must be an existing folder on your C drive. I used a generic name
"MyFolder" to be a placeholder for your real folder path.

--

Ken Snell
<MS ACCESS MVP>
http://www.accessmvp.com/KDSnell/
 
Sorry, I misunderstood about you having a MyFolder.

Aha, I see that you're using a macro. Change the File Name argument to this
(be sure to include the = sign):

="C:\MyFolder\Filename" & Format(Date(), "yyyymmdd") & ".csv"

--

Ken Snell
<MS ACCESS MVP>
http://www.accessmvp.com/KDSnell/
 
Back
Top