lotus的Notes数据导入导出到Excel表格的源代码
关于Notes数据导入导出到Excel表格中的问题
在网上也搜过一些代码,但是都报错了,而且是获取不到@ViewTitle(我理解为视图标题),然后还有几处都为报错
Sub Click(Source As Button)
On Error Goto errorMessage
Dim session As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim view As NotesView
Dim excelApplication As Variant
Dim excelWorkbook As Variant
Dim excelSheet As Variant
Dim i As Integer
Dim excelSave As New NotesUIWorkspace
Dim excelFileName As Variant
Dim viewName As Variant.毕业论文
Set doc = session.DocumentContext
viewName = Evaluate(|@Text(@ViewTitle)|,doc)
Msgbox "view:" + viewName(0)
Forall v In viewName
Msgbox "viewname:" + v
End Forall
Set db=session.CurrentDatabase
viewName=view.Name
Set view=db.GetView(viewName)
Set doc=view.GetFirstDocument
If Not(doc Is Nothing ) Then
Set excelApplication=CreateObject("Excel.Application")
excelFileName=excelSave.SaveFileDialog(False,"选择您所要保存的路径","dd")
If excelFileName(0) <>"" Then
excelFileName(0)=excelFileName(0)+".xls"
End If
If Not(Isempty(excelFileName)) Then
excelApplication.Visible = True
Set excelWorkbook=excelApplication.Workbooks.Add
Set excelSheet = excelWorkbook.Worksheets("Sheet1")
excelSheet.Cells(1,1).Value="周报标题"
excelSheet.Cells(1,2).Value="部门"
excelSheet.Cells(1,3).Value="职位"
i=1
Dim j,z As Variant
j=0
j=j+1
z=j
While Not(doc Is Nothing)
i=i+1
excelSheet.Cells(i,z).Value=doc.zbbiaoti(0)
excelSheet.Cells(i,z+1).Value=doc.bumen(0)
excelSheet.Cells(i,z+2).Value=doc.zwei(0)
Set doc=view.GetNextDocument(doc)
Wend
End If
End If
excelSheet.Columns("A").Select
excelSheet.Columns("A").EntireColumn.AutoFit
excelWorkbook.SaveAs(excelFileName(0))
excelApplication.Quit
Set excelApplication=Nothing
errorMessage:
If Error <> "" Then
Msgbox "错误信息: " +Error$ +" 错误行:"+Cstr(Erl)+"行"
End If
End Sub
Evaluate:
@Functions that affect the user interface do not work in the Evaluate method. These include: @Command, @DbManager, @DbName, @DbTitle, @DDEExecute, @DDEInitiate, @DDEPoke, @DDETerminate, @DialogBox, @PickList, @PostedCommand, @Prompt, and @ViewTitle.
viewName = Evaluate(|@Text(@ViewTitle)|,doc)
这个取不到值,Evaluate不能执行@ViewTitle,看上面的帮助。
恩,知道了,这个问题已经解决了。。。
还有一个问题想请教一下,就是您知道Notes中怎样导入Excel表格中的数据吗