Sample Code: Import data from a text file into notes database

This morning, I have a question for a member of mailing list, how we can
import data from a text file. Well I just have the code for that. Is quite
simple on how to import the data from a text file, but what you gonna do
with the data, is another question.

This a cut version of my lotusscript agent. I only show how we import the
data from a text file. My agent, actually use the data to create new
documents in notes database. The text file should located in the server
where the agent run. Also the signer of the agent must have appropriate
rights in the server.

In the agent, you will see the NoteLog object. Well, I have a habit to
create a log on every agent that I created. So I can troubleshoot the agent
easily if something goes wrong.

>>>>>
Sub Initialize
Dim fileNum As Integer
Dim strLine As String

‘//=====prepare for loging
Dim currentLog As New NotesLog( “Import data from text file” )
Call currentLog.OpenNotesLog( “”, “AMgrLog.nsf” )
‘//=====

fileNum = Freefile()
Open “c:\data\import\sample.txt” For Input As fileNum

‘//=====
Call currentLog.LogAction( “Import data from text file – Start”)
‘//=====

Do While Not Eof (fileNum)
Line Input #fileNum, strLine
‘//===now you have strLine variable that you can manipulate as
you want
‘//===example Trim(Mid$(strLine,69,7))
Loop

Close fileNum
‘//=====loging
Call currentLog.LogAction( “Import data from text file – End”)
Call currentLog.Close

End Sub
>>>>>

Now, you have it and have fun.

by

1 Comment


  1. // Reply

    Hi

    Can u explain elobarate code for import data from lotus notes
    fileds.

Leave a Reply