|
-
May 11th, 2007, 09:06 AM
#1
Thread Starter
New Member
[RESOLVED]Creating a file with today's date
Is creating a file with today's date as a name possible? If it is, how plz?
Thanks.
Last edited by OOGABOOGA; May 11th, 2007 at 09:41 AM.
-
May 11th, 2007, 09:09 AM
#2
Re: Creating a file with today's date
Code:
Open "d:\oogabooga" & Format(Now,"mm/dd/yyyy") & ".txt" For Append As #1
-
May 11th, 2007, 09:19 AM
#3
Re: Creating a file with today's date
Hack, is the ".txt" file name extension mandatory?. Just curious.
-
May 11th, 2007, 09:19 AM
#4
Addicted Member
Re: Creating a file with today's date
...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.
-
May 11th, 2007, 09:22 AM
#5
Re: Creating a file with today's date
No, the file extension isn't mandatory, but you should include one.
Are you creating text files?
-
May 11th, 2007, 09:27 AM
#6
Thread Starter
New Member
Re: Creating a file with today's date
I just get "Path not found" when i try either of youre ideas
-
May 11th, 2007, 09:28 AM
#7
Re: Creating a file with today's date
How can you get a "path not found" on a file that doesn't exist yet? 
What is the exact code that you are running?
-
May 11th, 2007, 09:29 AM
#8
Re: Creating a file with today's date
An alternative to Hack's solution:
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
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".
-
May 11th, 2007, 09:34 AM
#9
Thread Starter
New Member
Re: Creating a file with today's date
I've tried
Code:
Open "F:\New Folder" & Format(Now, "mm/dd/yyyy") & ".txt" For Append As #1
and
Code:
Dim monthfile As String
monthfile = "C:\" & Format(Now, "mm/dd/yyyy") & ".txt"
Open monthfile For Append As #20
Both of them give the same error.
-
May 11th, 2007, 09:36 AM
#10
Re: Creating a file with today's date
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
-
May 11th, 2007, 09:38 AM
#11
Thread Starter
New Member
Re: Creating a file with today's date
Yayyy works, thank.
-
May 11th, 2007, 09:40 AM
#12
Re: Creating a file with today's date
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. 
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.
-
May 11th, 2007, 09:44 AM
#13
Thread Starter
New Member
Re: [RESOLVED]Creating a file with today's date
Nope no more questions just yet.
And done
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|