How can I write a script to import some of the Excel rows into Lotus Notes as one document for each row of the Excel sheet?
Subject: How can I write a script to import some of the Excel rows into Lotus Notes as one document for each row of the Excel sheet?
Hello,
You can use the following code in a button.
Assuming there r 3 rows in the excel sheet with data
starting at row 2 and column 2
Sub Click(Source As Button)
Dim ws As New notesuiworkspace
Dim ss As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim xlapp As Variant
Dim filepath As String
Dim filearr As Variant
Dim docauthor As NotesItem
Set db=ss.CurrentDatabase
'Dim uidoc As NotesUIDocument
Dim fieldval As Variant
filearr=ws.OpenFileDialog(False)
If Isempty(filearr) Then
Exit Sub
End If
filepath=filearr(0)
Set xlapp=CreateObject("Excel.Application")
xlapp.Workbooks.Open(filepath)
xlapp.visible=False
‘’ Assuming Data Starts from 2nd row 2nd column
Dim xlr,xlc As Integer
xlr=2
'xlc=1
xlc=2
Dim ival As Variant
Dim chk As String
Dim item As NotesItem
Dim data(3) As String
Dim doccheck As String
Dim datacount , cntr As Integer
cntr =2
datacount =0
ival=xlapp.cells(xlr,xlc).value
doccheck=xlapp.cells(cntr,2).value
'No of Rows fetched from excel sheet stored in datacount variable ' ' '
While doccheck<>""
datacount=datacount + 1
cntr =cntr +1
doccheck=xlapp.cells(cntr,2).value
Wend
For x=2 To datacount +1
' ' ' Storing Each Excel Row In Array ( START ) ' ' '
data(1) = xlapp.cells(x ,1).value ' ' Doc Status
data(2) = xlapp.cells(x ,2).value ' ' Doc Creator
data(3) = xlapp.cells(x ,3).value ' ' Dt of Submission
' ' ' Storing Each Excel Row In Array ( END )' ' '
Set doc = db.CreateDocument
doc.Form="EmpDetails"
Call doc.Save(True,False)
doc.Status = Cstr( data(1) )
doc.Creator = Cstr( data(2) )
doc.DateOfSubmit = Cstr( data(3) )
Call doc.Save(True,False)
Next
ws.ViewRefresh
xlapp.Workbooks.Close
End Sub
Subject: RE: How can I write a script to import some of the Excel rows into Lotus Notes as one document for each row of the Excel sheet?
thank you for Replay
but I donot want to add all data into notes.
I want only those data which is not duplicated
Subject: How can I write a script to import some of the Excel rows into Lotus Notes as one document for each row of the Excel sheet?
you can also make a *csv file and read it like:
open xxx for input filenum
'here you can do what you want
close filenum
regards bernhard
Subject: RE: How can I write a script to import some of the Excel rows into Lotus Notes as one document for each row of the Excel sheet?
I want a script to import selected excel rows into Lotus Notes as one document for each row of the Excel sheet?
Subject: RE: How can I write a script to import some of the Excel rows into Lotus Notes as one document for each row of the Excel sheet?
so, copy the selected rows to a new excel sheet and save it as a csv file.
then make an Agent with the target none.
'read the file line for line and build new documents
open xxx for input filenum
array = split(line,delimiter)
set doc = new notesdocument(db)
doc.form = "yourForm"
doc.fielda = array(0)
doc.fieldb = array(1)
'and so on
call doc.save(true)
close filenum
regards bernhard