Solved

How to import Excel data and update Notes document

Posted on 2001-07-02
5
220 Views
Last Modified: 2013-12-18
I need to import selected data from Excel or 1-2-3 worksheet to Notes. How can I import selected field from Excel to update a specific field in Notes form, assuming both records have a common unique identifier field.
0
Comment
Question by:kamar
[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
  • 3
  • 2
5 Comments
 
LVL 4

Expert Comment

by:sloeber
ID: 6247594
Hey Kamar,

Here's an example of importing data from an excelfile to notes.
You can customize it, so that it works for you.
This is from a picture button in a navigator.
Import Excel Spreadsheet.

Sub Click(Source As Navigator)
     
     Dim filename As String
     Dim session As New NotesSession
     Dim db As NotesDatabase
     Dim Doc As NotesDocument
     Dim xlApp As Variant
     Dim xlsheet As Variant
     Set db = Session.currentdatabase
     filename =  Inputbox$("Enter name of Excel file. Ex: c:\test.xls", "Data Entry Box")
     If filename = "" Then
          Exit Sub
     End If
     Set xlApp = CreateObject("Excel.application")
     xlApp.Visible = False
     xlApp.Workbooks.Open filename
     Set xlsheet = xlApp.Workbooks(1).Worksheets(1)
     ARangeValue = xlsheet.Range("A1").Value
     i = 2
     Do Until ARangeValue = ""
          Set doc = db.CreateDocument
          doc.Name = xlsheet.Range("A" & Trim(Str(i))).Value
          doc.Address = xlsheet.Range("B" & Trim(Str(i))).Value
          doc.City = xlsheet.Range("C" & Trim(Str(i))).Value
          doc.State = xlsheet.Range("D" & Trim(Str(i))).Value
          doc.ZipCode = xlsheet.Range("E" & Trim(Str(i))).Value
          doc.form = "CI"
          Call Doc.save(True, False)
          i = i + 1
          ARangeValue =   xlsheet.Range("A" & Trim(Str(i))).Value
     Loop
     xlapp.activeworkbook.close
     xlapp.quit
     Set xlapp = Nothing
End Sub


Greets,
Sloeber
0
 

Author Comment

by:kamar
ID: 6247840
That will just import the data over, but I need to update an existing Notes record with a field from the Excel file using a common unique field. How do I do that?
0
 
LVL 4

Expert Comment

by:sloeber
ID: 6247901
That's the same way of working.
You just go to the document in your database and upadate the field, just like you create a new doc.

Else you must give me an example.

Greets,
Sloeber
0
 

Author Comment

by:kamar
ID: 6247999
Example:
I have a record in Notes with customer code CAT12 and expiry date 12/06/2002.  I have an 2 column Excel spreadsheet with list of customer codes and their new expiry date.  I need to update my old Notes record with this new one without manually opening the Notes form and type in. Is there a way to use an Agent to do all that automatically?
0
 
LVL 4

Accepted Solution

by:
sloeber earned 100 total points
ID: 6248107
Sub Click(Source As Navigator)
   
    Dim filename As String
    Dim session As New NotesSession
    Dim db As NotesDatabase
    Dim Doc As NotesDocument
    Dim xlApp As Variant
    Dim xlsheet As Variant
    Dim CustCode as string
    Dim CustExp as string
    Set db = Session.currentdatabase
    set view = db.getview("yourViewWithDocuments")
    set doc = view.getfirstdocument
    filename =  Inputbox$("Enter name of Excel file. Ex: c:\test.xls", "Data Entry Box")
    If filename = "" Then
         Exit Sub
    End If
    Set xlApp = CreateObject("Excel.application")
    xlApp.Visible = False
    xlApp.Workbooks.Open filename
While Not ( doc Is Nothing )
    CustCode = doc.CustCode(0)
    Set xlsheet = xlApp.Workbooks(1).Worksheets(1)
    ARangeValue = xlsheet.Range("A1").Value
    i = 2
    Do Until ARangeValue = ""
         
         if CustCode = xlsheet.Range("A" & Trim(Str(i))).Value then {
         doc.CustExp = xlsheet.Range("B" & Trim(Str(i))).Value
         Call Doc.save(True, False)
         End if
         i = i + 1
         ARangeValue =   xlsheet.Range("A" & Trim(Str(i))).Value
    Loop
    set doc = view.getnextdocument(doc)
wend
    xlapp.activeworkbook.close
    xlapp.quit
    Set xlapp = Nothing
End Sub


Greets,
Sloeber

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

For Desktop Techs: How to retain a user's Notes configuration data when swapping out the end user's computer. (Assuming that you are not upgrading to a completely different version of Notes client) All you need to do is: 1) install Notes o…
Lack of Storage capacity is a common problem that exists in every field of life. Here we are taking the case of Lotus Notes Emails, as we all know that we are totally depend on e-communication i.e. Emails. This article is fully dedicated to resolvin…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

726 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