Auto Naming an exported file.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need to export/send(via email) a table from my data base. I can do this
with no problem, but I need the file to be renamed with the name of the table
and the date and time needs attached automaticallty to this file. Eg:
CSV.txt needs to be sent as = CSV2.8.0609:00am.txt. Can this be done in a
macro or visual basics.? If anyone can suggest a method, it would be very
appreciated!
 
Well, you can't include : in a file name, but other than that, yes, it's
quite simple to do using VBA.

Create a variable that has the desired name, and use that variable name
instead of hard-coding the export name.

I'm assuming that "2.8.06" in your sample name is supposed to be the date in
m/d/yy format, so something like:

strFileName = "CSV" & Format(Now(), "d\.m\.yyhh\.nnam/pm") & ".txt"
 
Back
Top