Domino Code Fragment

Code Name*
export to text
Date*
06/07/2002
Source (or email address if you prefer)*
brigitte
IP address:.193.175.168.237
Description*
Exports a view to a textfile which can be used in Excel
Type*
LotusScript
Categories*
File Input/Output
Implementation:
None (plug and play)
Required Client:
(none)
Server:
(none)
Limitations:
Comments:
Files/Graphics attachments (if applicable): Code:
This function searches the string "suchen" in the string "feld" and replaces it by "ersetzen". If "suchen" appears several times, all occcurances are replaced. The function is used in the sub below.

Function replace(feld As String, suchen As String, ersetzen As String)
Dim zwischen, links, rechts As String
Dim laenge, pos As Integer

zwischen = feld
pos = Instr (1,zwischen,suchen)
laenge = Len(zwischen)
While pos > 0
links = Left(zwischen,pos-1)
rechts = Right(zwischen,laenge-(pos+1))
zwischen = (links+ersetzen+rechts)
pos = Instr (1,zwischen,suchen)
laenge = Len(zwischen)
Wend
replace=zwischen

End Function

I made some changes to the sub ExportView in your list (thank you in the first place!!). Now the sub is able to handle multiple values and it replaces carriage returns in an item by blanks, so that the textfile can be opened in Excel without having problems with the columns.

Sub ExportView(pView As NotesView, pPathAndFileName As String, pDelimiter As String)
Dim doc As NotesDocument

Dim ExportLine, Feld As String
Dim LineCount, cc, maxcc, ic, maxic As Integer
Dim mehrfach As Variant


'Reset File Handles
Close
Reset

'Open the File Handle
ExportFile = Freefile
Open pPathAndFileName For Output As ExportFile

'Begin loop through the view
maxcc = pView.columncount
ExportLine = ""

'Export of columntitles in the first line
Forall c In pView.Columns
Print c.Title
ExportLine = ExportLine & c.Title & pDelimiter
End Forall
Print #ExportFile, ExportLine

Set doc = pView.GetFirstDocument
While Not (doc Is Nothing)
'Initialize the export line
ExportLine = ""

'Use the ColumnValues property of the document as defined in NotesDocument. Returns what appears in the view.
For cc=0 To maxcc-1

'Just in case the view has a list displayed........
If Not Isarray(doc.columnvalues(cc)) Then
'Append the Export Line with the current text value, carriage return is replaced by blank
Feld = Trim(Cstr(doc.columnvalues(cc)))
Feld = replace(feld,Chr(13)," ")
ExportLine = ExportLine & feld & pDelimiter
Else
'If it is an array return all elements of the array
maxic = Ubound(doc.columnvalues(cc))
Redim mehrfach (maxic) As Variant
mehrfach = doc.columnvalues(cc)

For ic = 0 To maxic-1
ExportLine = ExportLine & Trim(Cstr(mehrfach(ic))) & ";"
Next ic
ExportLine = ExportLine & Trim(Cstr(mehrfach(maxic))) & pDelimiter
End If
Next cc
'Increment Counter
LineCount = LineCount + 1
'Update Status
Print "Exporting Line - " & Cstr(LineCount)
'Write line to the file handle
Print #ExportFile, ExportLine
'Get the next document
Set doc = pView.GetNextDocument(doc)
Wend
Print "Complete. " & Cstr(LineCount) & " documents exported to " & pPathAndFileName
'Reset File Handles

Close
Reset
End Sub