'Untitled ex: Option Public Option Explicit Dim xlApp As Variant Dim xlWorkbook As Variant Dim xlSheet As Variant Const xlLeft% = -4131 Const xlCenter% = -4108 Const xlRight% = -4152 Dim Columns(1 To 24) As String Sub Initialize Dim ws As New NotesUIWorkspace Dim uiview As NotesUIView Dim view As NotesView ' use the workspace to get the current view Set uiview = ws.CurrentView Set view = uiview.View Dim filenames As Variant Call ViewExcelPrint (view) End Sub Sub Terminate End Sub Sub InitialExcelSheet () On Error Goto InitializeExcelError ' Set up the Excel Spreadsheet. Set xlApp = createObject( "Excel.Application" ) Set xlWorkbook = xlApp.Workbooks xlWorkbook.Add Set xlSheet = xlApp.Workbooks(1).Worksheets(1) Exit Sub InitializeExcelError: Messagebox "(InitialExcelSheet) Error" & Str( Err ) & ": " & Error$ & " - process aborted" ' Shut down Excel. ShutDownExcel End Sub Sub ShutDownExcel ' Shut down Excel. xlApp.DisplayAlerts = False xlApp.ActiveWorkbook.close xlApp.Quit Set xlSheet = Nothing Set xlWorkbook = Nothing Set xlApp = Nothing End Sub Sub ViewExcelPrint (view As Notesview) Call intializeColumnArrayValues Call InitialExcelSheet () Dim fileNum As Integer Dim entry As NotesViewEntry Dim vc As NotesViewEntryCollection Dim rowstring As String Dim cns As String Dim ColCount As Integer Dim RowCount As Integer ColCount = 0 ' use the view column titles as the CSV headers Forall c In view.Columns ColCount = ColCount + 1 Call AddExcelValue (ColCount, 1, Cstr(c.title )) End Forall Dim MaxColumnCount As Integer MaxColumnCount = ColCount ' now get and print the values for each row and column RowCount = 2 ' start the rows of data on the third (3) row in the spreadsheet Set vc = view.AllEntries Set entry = vc.GetFirstEntry() While Not entry Is Nothing RowCount = RowCount + 1 ColCount = 0 Forall colval In entry.ColumnValues ColCount = ColCount + 1 Call AddExcelValue (ColCount, RowCount, ColVal ) End Forall Set entry = vc.GetNextEntry(entry) Wend ' fit the columns xlSheet.Range( "A1:" + Columns(MaxColumnCount) + Cstr( RowCount ) ).Columns.AutoFit ' do formatting for text column headers xlSheet.Range( "A1:"+Columns(MaxColumnCount)+"1" ).Borders.LineStyle = 7 With xlSheet.Range( "A1:"+Columns(MaxColumnCount)+"1" ).Font ' Font size, colour, style. .Size = 9 .Bold = True .ColorIndex = 0 End With ' do a split so the column headers are allways at the top xlSheet.Rows("1:1").Select With xlApp.ActiveWindow .SplitColumn = 0 .SplitRow = 2 End With xlApp.ActiveWindow.Panes(1).Activate xlSheet.Range("A1:"+Columns(MaxColumnCount)+"1").Select xlApp.ActiveWindow.FreezePanes = True ' show the spreadsheet xlApp.Visible = True End Sub Sub intializeColumnArrayValues Columns(1) = "A" Columns(2) = "B" Columns(3) = "C" Columns(4) = "D" Columns(5) = "E" Columns(6) = "F" Columns(7) = "G" Columns(8) = "H" Columns(9) = "I" Columns(10) = "J" Columns(11) = "K" Columns(12) = "L" End Sub Sub AddExcelValue (Column As Integer, Row As Integer , Value As Variant) xlSheet.Range( Columns(Column) + Cstr(Row) ).Value = Value End Sub