Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

automatic naming of sequential txt files 2

Status
Not open for further replies.

srgoodall

Electrical
Feb 8, 2008
4
0
0
US
I am trying to write vb code to automatically name a txt file I wish to save in a sequential file based upon the current month. For example, in the stmt

Open "c:\Month.txt" for Output as #1


I would like to have "Month" in "Month.txt" be a variable that can be assigned with a stmt like

Month = Format(Date, "mmmm").

Problem is, in the Open stmt above, the word Month is taken as a literal name.

I suspect there is a way to do this, but I'm just learning vb.

Thanks very much.
 
Replies continue below

Recommended for you

Its been awhile but something like this might work

Filename1 = "c:\month.txt". Watch using "filename" - it may be a reserved word.

Then:

Open filename1 for Output as #1

 
Open "C:\" & format(Date, "mmmm") & ".txt" for output as #1

Incidentally you should use freefile rather than hardcoding the number

 
Status
Not open for further replies.
Back
Top