This post is part of the series on VBA Snippets.
The below VBA script can be used to open a text file for appending and then write a line to the bottom of the file; it could be combined with the example in this eries’ last post on selecting records from a Microsoft Dynamics ODBC connection to out put multiple lines.
The highlighted section is the path of the output file.
Dim objFSO As FileSystemObject
Dim objTextStream As TextStream
Const fsoForAppending = 8
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextStream = objFSO.OpenTextFile(output path, fsoForAppending, True)
'Write line
objTextStream.WriteLine data to output
objTextStream.Close
Set objTextStream = Nothing