Friday, December 30, 2011

Create document from Text file in Lotus Notes

This article about import data from txt document .

Step 1:

create one .txt document like below.

“hi”, “8585885858″



“krishna”, “8585885858″

and save name as test

Step 2:

create one form and name as “mahe” and create two field (i) name1 (II) mobile

save the form and map this form to one view and also map field to columns


create one lotus script agent and paste following code

Option Public

Sub Initialize

Dim session As New NotesSession

Dim db As NotesDatabase

Set db = session.CurrentDatabase

Dim uiws As New NotesUIWorkspace

Dim fileCSV As Variant

‘Declare variables to hold data

Dim Name1 As String

Dim mobile As String

Dim counter As Integer

Dim doc As NotesDocument

counter =0

’setup file number

filenum% = FreeFile()

‘Ask user for file location

fileCSV = uiws.OpenFileDialog(False, “Choose the CSV file”,”*.txt” ,”c:\temp”)

‘If the user chose a file then process

If Not IsEmpty(fileCSV ) Then

Open fileCSV(0) For Input As filenum%

Do Until EOF(filenum%)

‘Read a line of data

Input #filenum%, name1, mobile

‘Create Notes document and write values to it

Set doc = db.CreateDocument

With doc




End With

’save document

Call, False)

counter = counter +1


MsgBox “You imported ” & counter & ” records.”

End If

End Sub

Step 4:

run the agent and select test.txt and go back to view you can see imported file

No comments:

Post a Comment