Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create a New File

Status
Not open for further replies.

smartrider

Programmer
Apr 18, 2003
21
US
How can I do the following :

I am writing a program where the data get saved from the UserForm to a text file but right now I can already created a text file .How can I do something like when the Program runs - it will look for a text file and it can't find it then it will create it for you.

Please Help !!

Thanks.
 

Use Dir to see if the file exists.
If yes, then Open for Append.
If not, then Open for Output.
Write to the file.
Close the file.

If Dir("File.Dat") > "" Then
Open "File.Dat" For Append As #1
Else
Open "File.Dat" For Output As #1
EndIF

For A = 0 To UBound(Answer$)
Print #1, Answer$(A)
Next

Close #1
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top