1. 程式人生 > 其它 >匯出文件資訊到Excel表格

匯出文件資訊到Excel表格

技術標籤:Domino

程式碼如下:

Sub Initialize
	On Error GoTo errhandle
	
	'定義變數
	Dim session As New NotesSession
	Dim db As NotesDatabase
	Dim dc As NotesDocumentCollection
	Dim doc As NotesDocument
	
	'定義Excel變數
	Dim excelApplication As Variant
	Dim excelWorkbook As Variant
	Dim excelSheet As Variant
	
	'初始化變數
	Set db = session.Currentdatabase
	Set dc = db.Unprocesseddocuments
	If dc.Count = 0 Then
		Exit sub
	End If
	
	Set excelApplication = CreateObject("Excel.Application")
	Set excelWorkbook = excelApplication.Workbooks.Add
	Set excelSheet = excelWorkbook.Worksheets("Sheet1")
	'
先不展示excel表 excelApplication.visible = False '迴圈所選擇的文件集合 Dim i As Integer,L As Integer L = 1 For i = 1 To dc.Count Set doc = dc.Getnthdocument(i) excelSheet.cells(L,1).value = "賦值1" excelSheet.cells(L,2).value = "賦值2" L = L + 1 Next excelApplication.visible =
true Exit Sub errhandle: excelApplication.visible = true MsgBox Erl & Error Exit sub End Sub