Is creating a file with today's date as a name possible? If it is, how plz? :p
Thanks.
Printable View
Is creating a file with today's date as a name possible? If it is, how plz? :p
Thanks.
Code:Open "d:\oogabooga" & Format(Now,"mm/dd/yyyy") & ".txt" For Append As #1
Hack, is the ".txt" file name extension mandatory?. Just curious.
...and if you are planning to create several files on the same date, you may want to add the time to the file name.
Suggest you might consider something like:
strT = Format$(Now,"yyyy-mm-dd-hh-nn-ss")
strFileName = "D:\" & strT & "-OOGABOOGA.TXT"
Note they will also be sortable in Windows Explorer using this type of format, based on date and time created.
No, the file extension isn't mandatory, but you should include one.
Are you creating text files?
I just get "Path not found" when i try either of youre ideas :confused:
How can you get a "path not found" on a file that doesn't exist yet? :confused:
What is the exact code that you are running?
An alternative to Hack's solution:
Note that when you run this after midnight tonight, a new file will be created. Until then, you can work with the same file name, which on the second excecution and thereafter, it is no longer "new".Code:Dim MyFile As String
Private Sub Form_Load()
MyFile = Date$
Open MyFile For Binary As #1
Close
MsgBox "My new file is named " & MyFile ' Returns 3-11-2007
End Sub
I've tried
andCode:Open "F:\New Folder" & Format(Now, "mm/dd/yyyy") & ".txt" For Append As #1
Both of them give the same error.Code:Dim monthfile As String
monthfile = "C:\" & Format(Now, "mm/dd/yyyy") & ".txt"
Open monthfile For Append As #20
CodeDoc has pointed out a flaw in my example. Windows does not like "/" in file names so you would need to format it as mm-dd-yyyy
Yayyy works, thank. :D
Sorry for the confusion. I am just sooooooooooo used to Formatting dates with the / character that I just typed that out without thinking about how it was going to be used. :blush:
Do you have any other questions?
If not, you could help us out by pulling down the Thread Tools menu and click the Mark Thread Resolved menu item. That will let everyone know that you have your answer.
Thank you. :)
Nope no more questions just yet.
And done :D