关闭

导到Excel,

540人阅读 评论(0) 收藏 举报

Sub Click(Source As Button)
 Dim ws As New NotesUIWorkspace
 Dim session As New notessession
 
 Dim uidoc As NotesUIDocument
 Dim doc As NotesDocument
 Dim files As Variant
 Dim v As Variant
 Dim excelApplication As Variant
 Dim excelWorkbook As Variant
 Dim excelsheet As Variant
 
 ret = Messagebox("Are you sure you want to export data to excel」ソ",4 + 32,"")
 If  ret= 7 Then
  Exit Sub
 End If
 
 files = ws.SaveFileDialog( False,"File name",, "c:/", "data.xls")
 
 Set excelApplication=CreateObject("Excel.Application")
 Set excelWorkbook = excelApplication.Workbooks.Add
 Call excelWorkbook.SaveAs(files(0))
 
 
 Set excelsheet=excelWorkbook.Sheets.add
 
 excelsheet.name="itemname"
 
 excelSheet.Cells(1,1).Value="FormName"
 excelSheet.Cells(1,2).Value="FieldName"
 excelSheet.Cells(1,3).Value="FieldType"
 excelSheet.Cells(1,4).Value="FieldSize"
 excelSheet.Cells(1,5).Value="values"
 count=2
 
 Dim db As NotesDatabase
 Dim view As notesview
 Dim vdoc As NotesDocument
 
 Set db=session.CurrentDatabase
 Set view=db.GetView("AllDoc")
 Set vdoc=view.GetFirstDocument
 While Not(vdoc Is Nothing)
  excelSheet.Cells(count,1).Value=vdoc.FormName(0)
  excelSheet.Cells(count,2).Value=vdoc.FieldName(0)
  excelSheet.Cells(count,3).Value=vdoc.FieldType(0)
  excelSheet.Cells(count,4).Value=vdoc.FieldSize(0)
  excelSheet.Cells(count,5).Value=vdoc.values(0)
  count=count+1
  Set vdoc =view.GetNextDocument(vdoc)
 Wend
 excelWorkbook.save
 excelWorkbook.close(False)
 excelApplication.Quit
 Set excelApplication=Nothing
 ret =Messagebox("The data export succeed」。",0 + 64,"S")
End Sub

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:13246次
    • 积分:181
    • 等级:
    • 排名:千里之外
    • 原创:4篇
    • 转载:10篇
    • 译文:0篇
    • 评论:4条
    文章分类
    最新评论