Call the following agent in an action button to export selected documents in the view to symphony Spreadsheet.
Note : For better output you have to map all required fields in the view. And it will also ask the path to save the file which contains the exported data.
Sub Initialize
On Error GoTo errorHandler
Dim ses As New NotesSession
Dim ws As New NotesUIWorkspace
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim stuDetailsView As NotesView
Dim viewEntryCollection As NotesViewEntryCollection
Dim viewEntry As NotesViewEntry
Dim i As Integer
Dim j As integer
Dim cnam As Variant
Set db = ses.CurrentDatabase
Set stuDetailsView=db.GetView(”vwStudent”)
‘Assign ‘vwStudent’ view as NotesView
Set viewEntryCollection=stuDetailsView.AllEntries
‘ViewEntryCollection contains the handle of all documents in the view
Set viewEntry=viewEntryCollection.GetFirstEntry
‘View Entry have the handle of first document from the ViewEntryCollection
Dim fileNum As Integer
Dim fileName As String
fileNum = FreeFile()
‘Gives a file number between 0 to 255 which is currently free
Dim saveas As Variant
saveas = ws.SavefileDialog(False,,”Symphony Word | *.odt”,,”All Documents To Symphony Word.odt”)
‘Opens a file save dialog box and ask user where to save the Created document, The file name is default
If IsEmpty(saveas) Then
Exit sub
End If
fileName = saveas(0)
‘Assigning the filename with full path which is given by the user
Open fileName For Output As fileNum
‘Opens the created file with reference to the file number and ready to write in it
Print #fileNum,”
Student Details
‘ Document heading
Print #fileNum,”
‘Creates a table in center of the Symphony Document
Print #fileNum,”
”‘Writes the Column header in the first row of the table
For j=1 To stuDetailsView.EntryCount
‘Loop runs for all documents in the view and exits
Print #fileNum,”
”For i=0 To stuDetailsView.ColumnCount-1
‘Loop runs for all columns in the each documents in the view
Print #fileNum, “
”‘Writes all column values inside the table in the documents corresponding to the view
Next i
Set viewEntry=viewEntryCollection.GetNextEntry(viewEntry)
‘ Getting the next entry from the collection
Print #fileNum,”
”Next j
Print #fileNum,”
Student Name | Student RegNo | Date of Birth | Department | Batch | College Name |
---|---|---|---|---|---|
” & viewEntry.ColumnValues(i) & “ |
‘Closes the table
Close fileNum
Print “Symphony Document Report Generated Successfully”
‘Displays this message in the status bar
Exit Sub
errorHandler:
MsgBox “Line No :” & Erl()& Chr(13) &”Error : ” & Error()
‘ Prints the error and the line number where the error occurs
Exit Sub
End Sub
No comments:
Post a Comment