About This Code
Brief Description:
Export all group members in CSV file
Contributor:
laurent abcdef
Type:
Document Management
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
Dim FileNum As Long
Dim LogError As String
Sub Initialize
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
Set doc = collection.GetFirstDocument()
While Not(doc Is Nothing)
Call InitExport( Doc.ListName(0) )
Call GroupExport( Doc.ListName(0) )
Call TerminateExport( )
Set doc = collection.GetNextDocument(doc)
Wend
print LogError
End Sub
Sub TerminateExport( )
Close #FileNum
End Sub
Sub GroupExport( GroupName As String )
Dim Session As New NotesSession
Dim DB As NotesDatabase
Set DB = Session.CurrentDatabase
Dim AllUsersView As NotesView
Set AllUsersView = DB.GetView( "($Users)" )
Dim Doc As NotesDocument
Set Doc = AllUsersView.GetDocumentByKey( GroupName , True )
If Doc Is Nothing Then
LogError = LogError + " Groupe/User introuvable : " + GroupName + Chr$(10)
Exit Sub
End If
If Doc.Type(0) = "Group" Then
Forall OneMember In Doc.Members
GroupExport( OneMember )
End Forall
Elseif Doc.Type(0) = "Person" Then
Print #FileNum, |"| + Doc.FullName(0) + |"|
End If
End Sub
Sub InitExport( GroupName As String )
FileNum = Freefile()
Open "c:\TEMP\Export CSV of " + GroupName + ".CSV" For Output Access Write As FileNum
End Sub
Usage / Example
Create an agent with the code in Names.nsf
Select one or more group, launch the agent
A CSV file will be created with all the users members, note if the group contains sub-group they will be expended