Last active
March 13, 2017 09:38
-
-
Save XPagesAndMore/219b0568c4b723453aa628de546696f0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub Initialize | |
Dim session As New NotesSession | |
Dim db As NotesDatabase | |
Dim fileName As String | |
Dim fileNum As Integer | |
Dim headerstring As String | |
Dim values As String | |
Dim selection As String | |
Dim collection As NotesDocumentCollection | |
Dim doc As NotesDocument | |
On Error Resume Next | |
Set db = session.CurrentDatabase | |
ForAll form In db.Forms | |
If IsEmpty(form.Fields) Then | |
MessageBox form.Name & " has no fields" | |
Else | |
'Export Form | |
Dim fieldcount As Integer | |
Dim msgString As String | |
If form.Name = "FORMNAME" Then | |
fieldCount = 0 | |
msgString = "" | |
fileNum% = FreeFile() | |
fileName$ = "c:\temp\export\" & form.Name & ".csv" | |
Open FileName$ For Output As fileNum% | |
ForAll Field In form.Fields | |
msgString = msgString & Chr(10) & _ | |
"" & Field | |
fieldCount = fieldCount + 1 | |
headerstring=headerstring & |"| &Field &|",| | |
End ForAll | |
Write #fileNum%, |",| & headerstring & |"| | |
headerstring="" | |
Else | |
End If | |
End If | |
selection = |Form="| & form.Name & |"| | |
Set collection=db.Search(selection, Nothing, 0) | |
Dim x As Integer | |
Dim newvalue As Variant | |
Set doc = collection.GetFirstDocument | |
Do Until (doc Is Nothing) | |
values="" | |
ForAll formfield In form.Fields | |
newvalue=doc.GetItemValue(formfield) | |
values=values & |"| & newvalue(0) & |",| | |
End ForAll | |
Write #fileNum%, |",| & values &|"| | |
values="" | |
Set doc = collection.GetNextDocument(doc) | |
Loop | |
ForAll aliaz In form.Aliases | |
If aliaz = form.Name Then | |
GoTo NextAliaz 'alias is same as form name | |
End If | |
selection = |Form="| & aliaz & |"| | |
Set collection=db.Search(selection, Nothing, 0) | |
Set doc = collection.GetFirstDocument | |
Do Until (doc Is Nothing) | |
values="" | |
ForAll formfield In form.Fields | |
newvalue=doc.GetItemValue(formfield) | |
values=values & |"| & newvalue(0) & |",| | |
End ForAll | |
Write #fileNum%, |",| & values &|"| | |
values="" | |
NextAliaz: | |
Set doc = collection.GetNextDocument(doc) | |
Loop | |
End ForAll | |
Close fileNum% | |
End ForAll | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment