Your technology certification is waiting. Enroll in Cloud Class ®
Dim session As New NotesSession
Dim db As NotesDatabase
Dim ws As New NotesUIWorkspace
Dim view As NotesView
Dim doc As NotesDocument
Dim i As Integer
Dim strval As String
Dim retNames As Variant
Dim xlFilename As String '// This is the name of the Excel file that will be imported
'Ex: xlFilename = "D:\temp\test.xls"
retNames = ws.OpenFileDialog(False, "Choose the Excel file", "Excel File Sheets|*.xls", "D:\")
If Not Isarray(retNames) Then Exit Sub
xlFilename = retNames(0)
Set db = session.CurrentDatabase
Set doc = New NotesDocument(db)
'// Next we connect to Excel and open the file. Then start pulling over the records.
Dim Excel As Variant
Dim xlWorkbook As Variant
Dim xlSheet1 As Variant
Print "Connecting to Excel..."
Set Excel = CreateObject( "Excel.Application" )
Excel.Visible = False '// Don't display the Excel window
Print "Opening " & xlFilename & "..."
Excel.Workbooks.Open xlFilename '// Open the Excel file
Set xlWorkbook = Excel.ActiveWorkbook
Print "Importing data from the Excel file ..."
'the first sheet will be imported
Set xlSheet1 = xlWorkbook.WorkSheets(1)
'Cycle through the rows of the Excel sheet, pulling the data over to Notes
strval = Cstr( .Cells(i, 1).Value)
Print "processing "+Cstr(i)
Set doc = db.CreateDocument '// Create a new doc
doc.Form = "formname" '// (the name of the Notes form)
doc.Field1TX=Trim(Cstr( .Cells(i, 1).Value))
doc.Field2TX=Trim(Cstr( .Cells(i, 2).Value))
' continue with all other fields
Call doc.Save( True, True ) '// Save the new doc
i = i + 1
'// Close the Excel file without saving (we made no changes)
Print "Deconectare Excel..."
'// Close Excel
Set xlSheet1 = Nothing
Set xlWorkbook = Nothing
Set Excel = Nothing
'// Free the memory that we'd used
Print "A total of "+Cstr(i-3)+" docs were imported !" '// Clear the status lineEnd Sub
Open in new window
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Please enter a first name
Please enter a last name
Must be at least 4 characters long.
Join and Comment
From novice to tech pro — start learning today.
Premium members can enroll in this course at no extra cost.