I am trying to alter some script so that it will:
1 - Check to see if there is already a file created with the name ‘Credits.csv’
2 - If no, create this file
3 - If yes, append records to the file
I already have the code that will create the file. However, it does not check to see if the file already exists - it just overwrites the old file if it is there.
Here is my current code - can anyone tell me what I need to add to check for the existence of a file and append records if necessary?
Sub Initialize
Dim s As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument
Dim nbcol As Integer
Dim k As Integer
Dim newline As String
Dim fileName As String
Dim fileNum As Integer
Dim item As NotesItem
Set db = s.CurrentDatabase
Set view = db.GetView( "Send To JDE" )
nbcol = Ubound(view.Columns)
Set doc = view.getfirstdocument
fileName = "\\nt490001.test.com\groups\FTP\Credits\Credits.csv"
fileNum = Freefile()
Open fileName For Output As fileNum
k = 0
While Not (doc Is Nothing)
newline = ""
For k = 0 To nbcol
newline = newline + doc.ColumnValues(k)
If k <> nbcol Then newline = newline + ","
Next
Print #fileNum, newline
Set doc = view.GetNextDocument(doc)
Wend
Close fileNum
End Sub