Link to home
Start Free TrialLog in
Avatar of David Schmalzer
David SchmalzerFlag for United States of America

asked on

Export to Excel

I need an action button to export a view into an excel spreadsheet. Code anyone? Formula or Script. Version 4.6x
Avatar of zvonko
zvonko

Avatar of David Schmalzer

ASKER

Will this work for Notes 4.x as well?
All Notes properties I saw in this agent script are not new in R5.
I do not have any R4.x to test for you.

ASKER CERTIFIED SOLUTION
Avatar of pratigan
pratigan
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I have an easy script you can use in R4....Put this in an agent and just replace your field names....

Sub Initialize
     Dim session As New NotesSession
     Dim db As NotesDatabase
     Dim view As NotesView
     Dim dc As NotesDocumentCollection
     Dim Doc As NotesDocument
     
     Dim filename As String
     
     Dim i As Integer
     
     Dim xlApp As Variant
     Dim xlsheet As Variant
     
     Set db = Session.currentdatabase
     Set View = db.GetView( "New Users - Export" )
     Set ws = New NotesUIWorkspace
     
     filename = "C:\temp\temp"
     
     Set xlApp = CreateObject("Excel.application")
     
     xlApp.Visible = True
     
     xlApp.Workbooks.add
     Set xlsheet = xlApp.Workbooks(1).Worksheets(1)
     xlsheet.Activate
     xlsheet.Name = "request4dbammddyyyy"
' Build Header Row for Excel Spreadsheet
     
     
     'ARangeValue = xlsheet.Range("A1").Activate
     'xlsheet.Range("A" & Trim(Str(i + 1))).Value = "Column heading one"
     'xlsheet.Range("B" & Trim(Str(i + 1))).Value = "two"
     'xlsheet.Range("C" & Trim(Str(i + 1))).Value = "three"
     'xlsheet.Range("D" & Trim(Str(i + 1))).Value = "four"
     
' Build Document Collection for Export:
     Set dc = db.UnprocessedDocuments
     
     
' Export Data
     Set Doc = dc.GetFirstDocument
     i=-1
     For c = 1 To dc.count
          i=i+1
          xlsheet.Range("A" & Trim(Str(i + 1))).Value = doc.fieldone(0)
          xlsheet.Range("B" & Trim(Str(i + 1))).Value = doc.fieldtwo(0)
          xlsheet.Range("C" & Trim(Str(i + 1))).Value = doc.fieldthree(0)
          xlsheet.Range("D" & Trim(Str(i + 1))).Value = doc.fieldfour(0)
         
          Set Doc = dc.getnextdocument(Doc)          
     Next
     
     xlApp.Columns("A").Select
     xlApp.Selection.ColumnWidth = 13
     xlApp.Columns("B").Select
     xlApp.Selection.ColumnWidth = 30
     xlApp.Columns("C:D").Select
     xlApp.Selection.ColumnWidth = 15    
End Sub  

Samir