OpenNTF.org - Export Selected documents as C
My Links (Not logged in)
Code Bin Search
 
Hosted by Prominic.NET
Rate This Code
5 - brilliant stuff
4 - very nice
3 - average
2 - needs work
1 - bad
   OpenNTF Code Bin
About This Code
Brief Description:
Export Selected documents as CSV 
Rating:
Rating: 4 , Number of votes: 1 
Contributor:
laurent abcdef 
Category:
Lotusscript 
Type:
File I/O 
Document Release:
1.0 
Last Modified:
18 Sep 2008 
OpenNTF Disclaimer

All of the program code and information presented in the OpenNTF.org Code Bin are provided "as-is", and should be used at your own risk. OpenNTF.org make no express or implied warranty about anything in the Code Bin, and OpenNTF.org will not be responsible or liable for any damage caused by the use or misuse of anything from this site. OpenNTF.org makes no guarantees about anything. Please thoroughly test all of the knowledge and code you find here before you attempt to use them in your production environment.

Code / Description
Sub Initialize


Dim I As Long

Dim ExportedFields List As Long
Dim NombreExportedFields As Long

Const NomCSVFile = "C:\TEMP\Export.CSV"

Dim CSVFile As Long
CSVFile = Freefile()

Open NomCSVFile For Output Access Write As CSVFile

Dim session As New NotesSession
Dim db As NotesDatabase
Dim collection As NotesDocumentCollection
Dim doc As NotesDocument
Set db = session.CurrentDatabase
Set collection = db.UnprocessedDocuments

I=1
Set doc = collection.GetFirstDocument()
While Not(doc Is Nothing) And (I<50)

Forall ANotesItem In Doc.Items
If Not Iselement( ExportedFields( ANotesItem.Name ) ) Then
NombreExportedFields = NombreExportedFields + 1
ExportedFields( ANotesItem.Name ) = NombreExportedFields
End If
End Forall

I = I +1
Set doc = collection.GetNextDocument(doc)
Wend


Redim LigneOut( 1 To NombreExportedFields) As String


Forall UC In ExportedFields
LigneOut( UC ) = Listtag( UC )
End Forall

Call FlushLineOut( CSVFile , LigneOut )







Set doc = collection.GetFirstDocument()
While Not(doc Is Nothing)

Forall ANotesItem In Doc.Items
If Not Iselement( ExportedFields( ANotesItem.Name ) ) Then Error 9995
LigneOut( ExportedFields( ANotesItem.Name ) ) = ANotesItem.Values(0)
End Forall

Call FlushLineOut( CSVFile , LigneOut )

Call session.UpdateProcessedDoc( doc )
Set doc = collection.GetNextDocument(doc)
Wend

Close #CSVFile




End Sub










Sub FlushLineOut( FileNum As Long , LigneOut() As String )

Dim i As Long

For I = 1 To Ubound( LigneOut )

If I>1 Then Print #FileNum, |;| ;
Print #FileNum, |"| + LigneOut( I ) + |"| ;
LigneOut( I ) = ""

Next I

Print #FileNum, ""

End Sub

Usage / Example
Create an Agent with the code
select documents in view, then launch agent
 Comments

No documents found

 Add your comment!