This script export a notes view to a XLS file automatically !
Sub ExportXLS(Vue As String, Fichier As Variant)
'----------------------- Declarations ----------------------------------
Dim Session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument
Dim nbcol As Integer
Dim i,k As Variant
Dim Handle As Variant
Dim Wbook, Wsheet As Variant
Dim column As NotesViewColumn
'-------------------------------------------------------------------------------
Set db=Session.CurrentDatabase
Set view=db.Getview(Vue)
Set Handle=CreateObject("Excel.Application")
Set Wbook=Handle.Workbooks.Add
Set WSheet=Wbook.Worksheets(1)
k=0
nbcol = Ubound(view.Columns)
' Affiche le nom des colonnes dans la premi?re ligne du fichier Excel
Do
Set column=view.Columns(k)
Wsheet.Cells(1, k+1).Value=column.Title
k=k+1
Loop Until k=nbcol+1
' Remplit les cellules du fichiers avec les diff?rentes valeurs qui se
trouvent dans la vue
i=2
Set doc=view.Getfirstdocument()
While Not (doc Is Nothing)
For k = 0 To nbcol
Wsheet.Cells(i,k+1).Value=doc.ColumnValues(k)
Next
Set doc = view.GetNextDocument(doc)
i = i + 1
Wend
' Mise en page
Wsheet.Rows(1).Font.Bold=True
Wsheet.Rows(1).Font.Size=12
For k=1 To nbcol+1
Wsheet.Columns(k).Autofit
Next
Wbook.SaveAs(Fichier)
Wbook.close
Handle.Quit
Set Worksheet=Nothing
Set Workbook=Nothing
Set Handle=Nothing
End Sub
This was first published in November 2000