VBA to add a closing record in a CSV file

MarcelMegens

Registered User.
Local time
Today, 10:13
Joined
Jun 8, 2004
Messages
16
I have exported a CSV file from a table in access using transfertext in a macro. This works fine, but the receiver of this file wants to see a 9999 closing record in the CSV file without any junk after it.
I have tried adding a 9999 record, but this results in 9999 followed by a bunch of commas which I don't need. (see example)
field1,field2,field3,field4,field5
2006,15,12,13,14
2006,14,11,14,14
9999,,,


Can someone help me with some code that simply opens a named csv file, then add a line with 9999 and then saves the file ?
 
Put this in a STANDARD module and then call it after your other code (remember to pass it the file name):

Code:
Public Function Add9999(strFile As String)
    Open strFile For Append As #1
        Write #1, 9999
    Close #1
End Function
 

Users who are viewing this thread

Back
Top Bottom