[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

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

Posted on 2011-09-07
2
Medium Priority
?
725 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

What’s Wrong with Your Cloud Strategy ?

Even as many CIOs are embracing a cloud-first strategy, the reality is that moving to the cloud is a lengthy process and the end-state is likely to be a blend of multiple clouds—public and private. Learn why multicloud solutions matter in this webinar by Nimble Storage.

Question has a verified solution.

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

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

650 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