Append to Text File?

How can I open a text file and write (append) to it, beggining where I left off last time?
Who is Participating?
JuiletteConnect With a Mentor Commented:
'writing or reading data to or from a text file
'open for append adds the data to the end of file
'open for input opens the file for read only
'open for output opens the file and overwrites the file
Private Sub Command1_Click()

'this is the number of your file
Dim intFilenum As Integer

'set it to the next available free number
intFilenum = FreeFile

'this is your filename
Dim strFile As String
strFile = "A:\myfile.txt"

'this is the text you want to save (textbox)
Dim strText As String
strText = Text1.Text

'open the file for writing to as next freefile number

Open strFile For Append As intFilenum  'see above options
'write to the file
    Write #intFilenum, strText  'to read use  [input #filenum,strtext]

'close the file
Close intFilenum
End Sub
Simple Example:
(Include within a procedure)

dim msg

msg="The text to append"

Open "c:\test.txt" For Append As 1

Print #1, msg

Close 1

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.