Tip

Transfer Data into MS Excel'97 from Lotus Notes 4.X

This agent helps in transfering data from Notes into Excel.It has to be run from a view & can be run either on selected documents or all documents.


Sub Initialize
Dim fn As String
Dim Lfield As String
Dim Lvalue As String
Dim Status As String
Dim session As New NotesSession
Dim db As NotesDatabase
Dim AllView As NotesView
Dim Doc As NotesDocument
Dim j As Long
Dim dc As NotesDocumentCollection
Dim notesformula As String
Set db = Session.currentdatabase

NotesFormula = "Field form = " & |"Transfer"| ' Name of Form is Transfer

Set dc = db.FTSearch(notesformula,0)

Set doc = dc.getnthdocument(dc.count)

Set xlApp = CreateObject("Excel.application") 'Creates an Excel Object
xlApp.Visible = False
xlApp.Workbooks.Add

xlApp.Range("A1").Select
xlApp.Activecell.FormulaR1C1 = "One" 'One is the name of field on form Transfer
xlApp.Range("B1").Select
xlApp.Activecell.formulaR1c1 = "Two" ' Two is the name of field on form Transfer
xlApp.Range("C1").Select
xlApp.Activecell.formulaR1c1 = "Three"
'Three is the name of field on FormTransfer

For j = 1 To Dc.count
Set doc = dc.getnthdocument(j)
k = j + 1
ExcelARange ="A" & Trim(Str(k))
ExcelBRange = "B" & Trim(Str(k))
ExcelCRange = "C" & Trim(Str(k))
ExcelDRange = "D" & Trim(Str(k))

xlApp.Range(ExcelARange).select
xlApp.Activecell.formulaR1C1 = doc.One(0)
xlApp.Range(ExcelBRange).select
xlApp.Activecell.formulaR1C1 = doc.Two(0)
xlApp.Range(ExcelCRange).select
xlApp.Activecell.formulaR1C1 = doc.Three(0)
xlApp.Range(ExcelDRange).select

Next
On Error Resume Next
Kill "C:\push.xls"
On Error Goto 0
xlapp.activeworkbook.saveas "C:\push.xls" 'A file named push.xls is created in the root directory.
xlapp.activeworkbook.close
Set xlapp = Nothing 'Set the handle back to nothing.
End Sub

This was first published in November 2000

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.