?
Solved

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

Posted on 2011-09-07
2
Medium Priority
?
721 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 4

Accepted Solution

by:
cohalex earned 2000 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

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
This article covers general Notes 8.5 troubleshooting information including recreating the Notes\Data folder.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

752 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