Solved

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

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
How to get a file from SqlServer DB 4 29
Library to convert HTML to PDF. 8 46
Image(7) 1 37
ESXCLI upgrade command 1 27
Problem "Can you help me recover my changes?  I double-clicked the attachment, made changes, and then hit Save before closing it.  But when I try to re-open it, my changes are missing!"    Solution This solution opens the Outlook Secure Temp Fold…
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…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

746 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now