-----------------------------删除文档中指定的一个域(注:是删除整个域而不是域值)-----------------------------
Sub Initialize
On Error Goto a
Dim session As New NotesSession
Dim db As NotesDatabase
Set db = session.CurrentDatabase
Dim doc As NotesDocument
Set doc = db.GetDocumentByUNID("749E51D317265737482578E800295CFD") '通过ID获取到文档
Dim item As NotesItem
'方法一
'判断文档中是否有IP这个域,有责执行
While doc.HasItem("IP")
Set item = doc.GetFirstItem("IP")
Call item.Remove
Call doc.Save(True,True)
Wend
'方法二
While doc.HasItem("SYSF_CreateTime")
Call doc.RemoveItem("IP")
Call doc.Save(True,True)
Wend
Exit Sub
a:
Msgbox "错误在代理sz_test中的第" & Erl & "行-------:" & Error
End Sub
----------------------------------------在文档中新增一个域-----------------------------------------------------
Sub Initialize
On Error Goto a
Dim session As New NotesSession
Dim db As NotesDatabase
Set db = session.CurrentDatabase
Dim doc As NotesDocument
Set doc = db.GetDocumentByUNID("749E51D317265737482578E800295CFD") '通过ID获取到文档
'方法一:
'Set item = New NotesItem(doc,"Chr_test","付给域的值1")
'方法二:
'Call doc.AppendItemValue("Chr_test","付给域的值")
'方法三:
'doc.Chr_test = "付给域的值"
Call doc.Save(True,True)
Exit Sub
a:
Msgbox "错误在代理sz_test中的第" & Erl & "行-------:" & Error
End Sub
----------------------------------------修改文档中指定域的域值--------------------------------------------------
Sub Initialize
On Error Goto a
Dim session As New NotesSession
Dim db As NotesDatabase
Set db = session.CurrentDatabase
Dim doc As NotesDocument
Set doc = db.GetDocumentByUNID("749E51D317265737482578E800295CFD") '通过ID获取到文档
'方法一
doc.Subject = "bb"
'方法二
Dim item As NotesItem
Set item = doc.GetFirstItem("Subject")
item.Values = "aa"
Call doc.Save(True,True)
Exit Sub
a:
Msgbox "错误在代理sz_test中的第" & Erl & "行-------:" & Error
End Sub
----------------------------------------将一个文档中的域拷贝到另一个文档当中--------------------------------------------------
Sub Initialize
On Error Goto a
Dim session As New NotesSession
Dim db As NotesDatabase
Set db = session.CurrentDatabase
'原文档
Dim doc As NotesDocument
Set doc = db.GetDocumentByUNID("749E51D317265737482578E800295CFD") '通过ID获取到文档
'新文档
Dim tdoc As NotesDocument
Set tdoc = db.GetDocumentByUNID("F7F94A2B8C88EDAC482578E80028F254")
Dim item As NotesItem
Set item= doc.GetFirstItem("Chr_Test") '获得到原文档中的域
Call item.CopyItemToDocument(tdoc,"Chr_NewTest") '将原文档中Chr_Test域拷贝到新文档当中,并且可以将拷贝过来的域更改名称(Chr_NewTest)
Call tdoc.Save(True,True)
Exit Sub
a:
Msgbox "错误在代理sz_test中的第" & Erl & "行-------:" & Error
End Sub