Lotus数据导入(文本)

从文本导入
Sub Initialize
       On Error Goto UnknowError
       Msgbox "开始导入"
       Dim session As New NotesSession
       Dim db As NotesDatabase
       Dim view As NotesView
       Dim doc As NotesDocument
       Dim docPerson As NotesDocument
       Dim docTemp As NotesDocument
       Dim vFile As Variant
       Dim strMyname As String
       Dim strDeptNO As String
       Dim strDeptName As String
       Dim strFile As String
       Dim V1 As String
       Dim NO,myname,sex,deptNo,deptName,duty,office,phone,mobile,fax,mail,IP,postalcode,address,remark As String
      
       Set db=session.CurrentDatabase
       Set doc=session.DocumentContext
       vFile =Evaluate({@AttachmentNames},doc)
       strFile =Cstr(vFile(0))
       Msgbox strFile
       Dim ebd As NotesEmbeddedObject
       Set ebd=doc.GetAttachment(strFile)
       Msgbox ebd Is Nothing
       Call ebd.extractFile(strFile )
       Open strFile For Input As 10
       Dim i As Integer
       i=1
       If Not Eof(10) Then
              Input #10,V1
       End If
continue: Do While Not Eof(10)
              Input #10,V1
              If V1="" Then
                     Goto continue
              Else
                     myname=Strtoken(V1," ",1)
                     sex=Strtoken(V1," ",2)
                     deptName=Strtoken(V1,"      ",3)
                     duty=Strtoken(V1,"       ",4)
                     office=Strtoken(V1,"     ",5)
                     phone=Strtoken(V1,"     ",6)
                     mobile=Strtoken(V1,"    ",7)
                     fax=Strtoken(V1," ",8)
                     mail=Strtoken(V1," ",9)
                     IP=Strtoken(V1,"   ",10)
                     postalcode=Strtoken(V1,"      ",11)
                     address=Strtoken(V1,"   ",12)
                     remark=Strtoken(V1,"    ",13)
              End If
              If myname="" Then
                     Print {}
                     Goto continue
              End If
              If deptName="" Then
                     Print {}
                     Goto continue
              End If
              If phone="" Then
                     Print {}
                    
                     Goto continue
              End If
              If mobile="" Then
                     Print {}
                     Goto continue
              End If
              Set docPerson=db.CreateDocument
              docPerson.form="PersonInfo"
              docPerson.myName=myname
              docPerson.sex=sex
              docPerson.dept=deptName
              docPerson.duty=duty
              docPerson.office=office
              docPerson.phone=phone
              docPerson.mobile=mobile
              docPerson.fax=fax
              docPerson.mail=mail
              docPerson.IP=IP
              docPerson.postalcode=postalcode
              docPerson.address=address
              Dim ritem As NotesRichTextItem
              Set ritem=New NotesRichTextItem(docPerson,"remark")
              ritem.text=remark
              Call docPerson.Save(True,False)
       Loop
       Close #10
       Kill strFile
       Print {}
       Exit Sub
UnknowError:
       Msgbox "错误行:" & Erl & "错误信息:" & Error
       Exit Sub
End Sub

你可能感兴趣的:(Lotus)