David Schmalzer
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
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.
I do not have any R4.x to test for you.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.applic ation")
xlApp.Visible = True
xlApp.Workbooks.add
Set xlsheet = xlApp.Workbooks(1).Workshe ets(1)
xlsheet.Activate
xlsheet.Name = "request4dbammddyyyy"
' Build Header Row for Excel Spreadsheet
'ARangeValue = xlsheet.Range("A1").Activa te
'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.ColumnWidt h = 13
xlApp.Columns("B").Select
xlApp.Selection.ColumnWidt h = 30
xlApp.Columns("C:D").Selec t
xlApp.Selection.ColumnWidt h = 15
End Sub
Samir
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.applic
xlApp.Visible = True
xlApp.Workbooks.add
Set xlsheet = xlApp.Workbooks(1).Workshe
xlsheet.Activate
xlsheet.Name = "request4dbammddyyyy"
' Build Header Row for Excel Spreadsheet
'ARangeValue = xlsheet.Range("A1").Activa
'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.ColumnWidt
xlApp.Columns("B").Select
xlApp.Selection.ColumnWidt
xlApp.Columns("C:D").Selec
xlApp.Selection.ColumnWidt
End Sub
Samir
http://www.notes.net/sandbox.nsf/ecc552f1ab6e46e4852568a90055c4cd/e2a31b9d2a77f41685256b260050b64d?OpenDocument