Solved

How to transfer data from excel to lotus notes' form fields?

Posted on 2011-09-07
2
702 Views
Last Modified: 2013-12-18
What is the way to transfer data inside excel cell to Lotus Notes form fields?

Is it possible to do it with C#,.NET? or I have to use Lotusscript?

Can you give me a guiding place to look for code, or can you help me with the code ?

0
Comment
Question by:fatihdi
2 Comments
 
LVL 4

Accepted Solution

by:
cohalex earned 500 total points
ID: 36495689
Here is the LotusScript code.
It will ask fore the Excel file, than import all rows (staring with the second) from the first sheet.
The form will be specified as a field - see where the test value "formname" is given.

 
Sub ImportFise()
	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       
	With xlSheet1
		i=2
		strval = Cstr( .Cells(i, 1).Value)
		While strval<>""
			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
		Wend
	End With
	
	xlWorkbook.Close False
	'// Close the Excel file without saving (we made no changes)
	Print "Deconectare Excel..."
	Excel.Quit 
	'// 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
End Sub

Open in new window

0
 

Author Closing Comment

by:fatihdi
ID: 36496053
Thank you
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Notes Document Link used by IBM Notes is a link file which aids in the sharing of links to documents in email and webpages. The posts describe the importance and steps to create a Lotus Notes NDL file in brief.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question