关闭

在表单里使用excel工作表

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

Sub Click(Source As Button)

         Dim workspace As New NotesUIWorkspace

         Dim uidoc As NotesUIDocument

         Dim s As New NotesSession    

         Dim cdb As NotesDatabase

         Dim view As NotesView

         Dim doc As NotesDocument

         Dim MailInDbdoc As NotesDocument

         Dim Groupdoc As NotesDocument

         Dim people As NotesName     

         Dim handle As Variant

        

         Set cdb = s.CurrentDatabase  

         Set uidoc = workspace.CurrentDocument

//获取内嵌对象

         Set handle = uidoc.GetObject( "OLEREG" )

//获取工作表

         Set AppSheet=handle.sheets(1)

//从工作表中取值

         UserName = Replace(Trim(AppSheet.cells(1,1).value)," ","")

         i=1

//如果第一列(姓名)不为空值,即还有需要处理的人员

         Do While UserName<>""        

                   //从域里面取字符串     

                   O = uidoc.FieldGetText("O")

                   OU1 = Replace(Trim(uidoc.FieldGetText("OU1"))," ","")

                   //从工作表-单元格中取出数值

                   OU2 = Replace(Trim(AppSheet.cells(i,2).value)," ","")

                   RegServer = uidoc.FieldGetText("RegServer")

                   //生成用户名

                   Set people = s.CreateName(UserName+"/"+OU2+"/"+OU1+"/"+O)

                   If Not Check_People_Record(s,cdb.Server,people.Canonical) Then

                            If Not Check_Is_Double(Trim(UserName+"/"+OU2+"/"+OU1+"/"+O),cdb,"RegUserList_Back") Then

                                     Set doc = New NotesDocument(cdb)

                                     doc.O = O

                                     doc.OU1 = OU1

                                     doc.Depart = OU2

                                     doc.UserName = UserName

                                     doc.RegServer = RegServer

                                     doc.processed = "0"

                                     //指定文档所使用的表单

                                     doc.form = "frmRegUser"

                                     Call doc.ComputeWithForm(False,False)

                                     Call doc.Save(True,True)

                            End If

                   End If

                  

                   If Not Check_MailInDatabases_Record(s,cdb.Server,Trim(OU1+OU2+"邮箱")) Then

                            If Not Check_Is_Double(Trim(OU1+OU2+"邮箱"),cdb,"RegMailInDbList_Back") Then

                                     Set doc = New NotesDocument(cdb)

                                     doc.O = O

                                     doc.OU1 = OU1

                                     doc.Depart = OU2

                                     doc.RegServer = RegServer

                                     doc.processed = "0"

                                     doc.form = "frmRegMailInDb"

                                     Call doc.ComputeWithForm(False,False)

                                     Call doc.Save(True,True)

                            End If

                   End If

                  

                   If Not Check_Group_Record(s,cdb.Server,Trim(OU1+OU2+"全体人员")) Then

                            If Not Check_Is_Double(Trim(OU1+OU2+"全体人员"),cdb,"RegGroupList_Back") Then

                                     Set doc = New NotesDocument(cdb)

                                     doc.O = O

                                     doc.OU1 = OU1

                                     doc.Depart = OU2

                                     doc.RegServer = RegServer

                                     doc.processed = "0"

                                     doc.form = "frmRegGroup"

                                     Call doc.ComputeWithForm(False,False)

                                     Call doc.Save(True,True)

                            End If

                   End If

                   i=i+1

                   UserName = Trim(AppSheet.cells(i,1).value)

         Loop

         Msgbox "注册列表已产生!"

End Sub

0
0

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