This code will read a view and write selected fields out as a text file on the server then attach the file to a document while working from the Web. This allows users working from the Internet to download the attached text file and import it into a non-Lotus Notes product.
Sub Initialize
Dim Session As New NotesSession
Dim db As NotesDatabase
Dim View As NotesView
Dim rtitem As Variant
Dim plainText(4) As Variant
Dim fileNum As Integer
Dim item As NotesItem
Dim doc As NotesDocument
Dim rtitem1 As NotesRichTextItem
Dim object As NotesEmbeddedObject
Set db = Session.CurrentDatabase
Set View = db.GetView("AttendeesXL")
Set doc = View.GetFirstDocument
'declare file for output
fileNum = Freefile
Open "C:\NotesData.TXT" For Output As fileNum
'Loop through the view
While Not(doc Is Nothing)
Set doc2 = View.GetNextDocument(doc)
Set item = doc.GetFirstItem("lname")
plainText(1) = item.Text
Set item = doc.GetFirstItem("name")
plainText(2) = item.Text
Set item = doc.GetFirstItem("rank")
plainText(3) = item.Text
Write #fileNum, plainText(1), plainText(2), plainText(3)
Set doc = doc2
Wend
Close #fileNum
'The following imports the text file and attach to a document
Set doc = New NotesDocument(db)
Set rtitem1 = New NotesRichTextItem(doc, "BodyAtt")
Set object = rtitem1.Embedobject(EMBED_ATTACHMENT, "" , "C:\NotesData.TXT")
doc.Form = "DataTrForm"
Call doc.Save(True, True)
Print"[/DataTrView?OpenView]"
End Sub
This was first published in November 2000