View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
PVANS PVANS is offline
external usenet poster
 
Posts: 68
Default Save with filename ACJRNyyyymmddhhmm

Good morning

I am currently using the following code to save a worksheet as a custom .CSV
filetype:

intFile = FreeFile
Open "c:\test.txt" For Output As #intFile
For Each rngRow In ActiveSheet.UsedRange.Rows
strData = ""
For Each cell In rngRow.Cells
strData = strData & Trim(cell)
Next
Print #intFile, strData
Next
Close #intFile

As you can see, it saves the file as "test.txt". However, as I will need to
run this macro daily, I need to be able to save the file with the following
filename:
"ACJRNyyyymmddhhmm.txt" eg: today would be (assuming I ran the macro at the
time I wrote this query)
"ACJRN200909231006.txt"

Could someone please suggest a method that would achieve this desired
filename each day? Please note, it is critical that I keep the formatting,
within the file, that has been achieved by the above code.