Hallo zusammen,
ich hab hier ein wirklich nettes Script um Ansichten komplett und formatiert nach Excel zu exportieren - ist leider nicht von mir, ich poste es trotzdem, weil es wirklich gut ist. Danke an den unbekannten Programmierer!
Das ganze kopieren und als Aktion in die Ansicht einbinden - fertig...
Sub Click(Source As Button)
Dim Session As New NotesSession
Dim db As NotesDatabase
Dim sourceview As NotesView
Dim sourcedoc As NotesDocument
Dim dataview As NotesView
Dim datadoc As NotesDocument
Dim maxcols As Integer
Dim WS As New Notesuiworkspace
Dim UiView As notesuiview
Dim cols As Integer
Dim rows As Integer
Dim getfield As Variant
Set db = session.CurrentDatabase
Set UiView=WS.currentview
Set dataview = uiview.view
Dim xlApp As Variant
Dim xlsheet As Variant
Set xlApp = CreateObject("Excel.Application")
xlApp.StatusBar = "Import vorbereiten..."
xlApp.Visible = True
xlApp.Workbooks.Add
xlApp.ReferenceStyle = 2
Set xlsheet = xlApp.Workbooks(1).Worksheets(1)
xlsheet.Name = uiview.viewname
xlApp.StatusBar = "Überschriften erstellen..."
cols=1
Forall X In dataview.Columns
xlsheet.Cells(1,cols).Value =X.title
cols=cols+1
End Forall
xlApp.StatusBar = "Überschriften erstellen...fertig!"
xlApp.StatusBar = "Import vorbereiten..."
xlApp.StatusBar = "Daten importieren..."
Set datadoc = dataview.getfirstdocument
cols=1
rows=2
maxcols= dataview.columncount
While Not (datadoc Is Nothing)
For cols=0 To maxcols-1
getfield = Cstr(datadoc.ColumnValues( cols ))
xlsheet.Cells(rows,cols+1).Value = getfield
Next
rows=rows+1
cols=0
Set datadoc = dataview.getnextdocument(datadoc)
Wend
xlApp.StatusBar = "Import beendet! ... Formatieren starten"
xlApp.Rows("1:1").Select
xlApp.Selection.Font.Bold = True
xlApp.Range(xlsheet.Cells(1,1), xlsheet.Cells(1,maxcols)).Select
With xlApp.Selection.Interior
.ColorIndex = 15
.Pattern = 17 'xlGray16
.PatternColorIndex =6
End With
xlApp.StatusBar = "Titel formatiert"
xlApp.Rows("1:1").Select
xlApp.Selection.Font.Bold = True
xlApp.Range(xlsheet.Cells(1,1), xlsheet.Cells(rows,maxcols)).Select
xlApp.Selection.Font.Name = "Arial"
xlApp.Selection.Font.Size = 9
xlApp.Selection.Columns.AutoFit
With xlApp.Worksheets(1)
.PageSetup.Orientation = 2
.PageSetup.centerheader = "Report - Confidential"
.Pagesetup.RightFooter = "Page &P" & Chr$(13) & "Date: &D"
.Pagesetup.CenterFooter = ""
End With
xlApp.ReferenceStyle = 1
xlApp.Range("A1").Select
xlApp.StatusBar = "Fertig!"
End Sub