Solved

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

Posted on 2011-09-07
2
708 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

For beginners of Lotus Notes user this is important to know about the types of files and their location supported by IBM Notes. Mostly users are unaware about how many file types are created and what their usages are. This Article is fully dedicated…
This article covers general Notes 8.5 troubleshooting information including recreating the Notes\Data folder.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

856 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