Sub Initialize
Dim s As New NotesSession
Dim db As NotesDatabase
Dim fileNum As Integer, cells As Integer, k As Integer
Dim InputStr As String, delimiter As String
Dim FieldArray As Variant
Dim fieldNames As Variant
Set db = s.CurrentDatabase
fileNum% = Freefile()
fileName$ = "c:\temp\RISEImport.csv"
delimiter = ","
cells = 100
Open fileName$ For Input As fileNum%
Line Input #1, InputStr$
fieldNames = parseall(InputStr$, delimiter, cells,True)
On Error Resume Next
curRow=1
Do While Not Eof(fileNum%)
Print Cstr(curRow-1)
Set doc=New NotesDocument(db)
doc.Form="FProc"
Line Input #1, InputStr$
FieldArray = parseall(InputStr$, delimiter, cells,False)
For y=1 To Ubound(fieldNames)
Call doc.ReplaceItemValue(fieldNames(y), FieldArray(y))
Next
Call doc.save(True, False)
curRow=curRow+1
Loop
Close fileNum%
End Sub
Function parseall(Initialstr As String, delimiter As String, cells As Integer, titles As Boolean) As Variant
CRcr$ = Chr(13)
IniVar$ = initialstr
numchars = Len(IniVar$)
Redim cols(cells)
Redim coldata(cells)
cols (0) = 0
For numcol = 1 To cells
prevcol = cols(numcol -1 )
cols (numcol) = Instr (cols(numcol - 1) + 1, IniVar$, Delimiter$)
StartCol = Cols(numcol - 1) + 1
If Cols (numcol) = 0 Then
endcol = numchar + 1
Else
endcol = cols(numcol)
End If
FieldLenght = EndCol - StartCol
If FieldLenght <= 0 Then
FieldLenght = 50
End If
If titles And Trim$(Mid$(IniVar$, StartCol, FieldLenght))="" Then
Goto nomorefields
End If
ColData(numcol) = Trim$(Mid$(IniVar$, StartCol, FieldLenght))
CRPos% = Instr (1, ColData(numcol), CRcr$)
If (CRPos% >= 1) And (numcol <=2) Then
TempStr$ = ColData(numcol)
ColData(numcol) = Trim$(Mid$(IniVar$, StartCol, CRPos%-1))
End If
If cols (numcol) = 0 Then Exit For
Next
nomorefields:
Redim Preserve coldata(numcol)
parseall = coldata()
End Function
No comments:
Post a Comment