Sub Initialize
' 宣告Excel 相關變數
Dim ws As New NotesUIWorkspace
Dim session As New NotesSession
Dim db As NotesDatabase
Dim viewDeviation As NotesView
Dim docDeviation As NotesDocument
Dim aryKey(0 To 1) As String
Dim intIniRow As Integer
Dim xlApp As Variant
Dim xlSheet As Variant
Dim itemAuthor As NotesItem
Dim itemReader As NotesItem
Set db = session.CurrentDatabase
Set viewDeviation = db.GetView ("vwDeviationByCode")
FileName = "C:\Deviation.xls"
Set xlApp = CreateObject("Excel.application")
' xlApp.Workbooks.Add
' 開啟Sample檔案
xlApp.Workbooks.Open(FileName)
Set xlSheet = xlApp.Workbooks(1).Worksheets(1)
intIniRow=2
rowcount = 0
intRow = intIniRow
Do While ( xlSheet.Cells(intRow, 1).Value <> "" )
Select Case Trim(xlSheet.Cells(intRow, 1).Value)
Case "封裝生產部"
aryKey(0) = "TYPE1"
Case "最終測試生產部"
aryKey(0) = "TYPE2"
Case "晶圓測試生產部"
aryKey(0) = "TYPE3"
Case "COG生產部"
aryKey(0) = "TYPE4"
End Select
aryKey(1) = xlSheet.Cells(intRow, 2).Value
Set docDeviation = viewDeviation.GetDocumentByKey (aryKey,True)
If docDeviation Is Nothing Then
Set docDeviation = New NotesDocument(db)
docDeviation.Form = "Form-Deviation"
Set itemAuthor = New NotesItem(docDeviation,"DocAuthor","*",AUTHORS)
Set itemReader = New NotesItem (docDeviation,"DocReader","*",READERS)
docDeviation.Deviation_class = aryKey(0)
docDeviation.D_Code = aryKey(1)
End If
docDeviation.D_Ename = xlSheet.Cells(intRow, 4).Value
docDeviation.D_name = xlSheet.Cells(intRow, 3).Value
Call docDeviation.save(True,False)
intRow = intRow + 1
Loop
xlApp.Quit
Messagebox "Import ok! Rowcount : " & Cstr(intRow)
End Sub
沒有留言:
張貼留言