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