Contact US

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

automatic naming of sequential txt files

automatic naming of sequential txt files

automatic naming of sequential txt files

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.

RE: automatic naming of sequential txt files

Its been awhile but something like this might work

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


Open filename1 for Output as #1

RE: automatic naming of sequential txt files

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

Incidentally you should use freefile rather than hardcoding the number

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close