Object Lotus notes-引用文档。从NotesDocumentCollection
我有一个视图,上面有一个名为Object Lotus notes-引用文档。从NotesDocumentCollection,object,view,lotus-notes,Object,View,Lotus Notes,我有一个视图,上面有一个名为Delete 我想从视图中删除所有选定的文档;为此,我使用了: Dim session As New NotesSession Dim workspace As New NotesUIWorkspace Dim database As NotesDatabase Dim documentCollection As NotesDocumentCollection Set database=session.CurrentDatabase Set documentColl
Delete
我想从视图中删除所有选定的文档;为此,我使用了:
Dim session As New NotesSession
Dim workspace As New NotesUIWorkspace
Dim database As NotesDatabase
Dim documentCollection As NotesDocumentCollection
Set database=session.CurrentDatabase
Set documentCollection=database.UnprocessedDocuments
If documentCollection.Count=0 Then
Msgbox "No documents selected ",,"warning"
Else
userChoice=Msgbox ("Delete" & Cstr(documentCollection.Count) & " documents?",64+100, _
"Confirm...")
If userChoice=6 Then
Call documentCollection.RemoveAll(True)
Call workspace.ViewRefresh
End if
但是,如果我只想删除一些文档(从所有选中的文档中.from view),这些文档中的Value=YES
是文档中的一个文本字段,该怎么办
我试图声明:
Dim ui As NotesUIDocument
Dim doc As NotesDocument
Set doc=ui.document
但我得到的信息是:对象变量未设置
。所以我想我必须引用一个使用NotesDocumentCollection的文档?怎么做
谢谢你的时间 您需要循环浏览文档集合中的文档,然后单独处理它们。下面是一个使用documentCollection变量的循环示例:
Dim doc As NotesDocument
Set doc = documentCollection.GetFirstDocument
While Not(doc Is Nothing)
' Do stuff
' Get next document
Set doc = documentCollection.GetNextDocument(doc)
Wend
您需要遍历文档集合中的文档,然后逐个处理它们。下面是一个使用documentCollection变量的循环示例:
Dim doc As NotesDocument
Set doc = documentCollection.GetFirstDocument
While Not(doc Is Nothing)
' Do stuff
' Get next document
Set doc = documentCollection.GetNextDocument(doc)
Wend
您的错误消息与您的问题无关。。。错误消息来自将文档表单设置为单元化uidoc。您需要在代码中的某个地方设置ui=ws.CurrentDocument,当然还需要将ws:
Dim ws声明为New NotesUIWorkspace
但是对于您的问题,您根本不需要ui文档。要仅删除部分选定文档,请在集合中循环并仅删除符合条件的文档:
Dim doc as NotesDocument
Dim nextDoc as NotesDocument
Set doc = documentCollection.GetFirstDocument()
While not doc is Nothing
Set nextDoc = documentCollection.GetNextDocument(doc)
if doc.GetItemValue( "Value" )(0) = "Yes" then
call doc.Remove(True)
end if
Set doc = nextDoc
Wend
或者,将集合缩减为仅包含符合条件的文档,然后删除整个集合:
Call documentCollection.FTSearch("[Value] = Yes",0)
Call documentCollection.RemoveAll()
但要小心:收集量会随着FTSearch而减少,根据数据库的FT索引设置,可能会得到“当然是”或“是”->不太可靠。您的错误消息与您的问题无关。。。错误消息来自将文档表单设置为单元化uidoc。您需要在代码中的某个地方设置ui=ws.CurrentDocument,当然还需要将ws:
Dim ws声明为New NotesUIWorkspace
但是对于您的问题,您根本不需要ui文档。要仅删除部分选定文档,请在集合中循环并仅删除符合条件的文档:
Dim doc as NotesDocument
Dim nextDoc as NotesDocument
Set doc = documentCollection.GetFirstDocument()
While not doc is Nothing
Set nextDoc = documentCollection.GetNextDocument(doc)
if doc.GetItemValue( "Value" )(0) = "Yes" then
call doc.Remove(True)
end if
Set doc = nextDoc
Wend
或者,将集合缩减为仅包含符合条件的文档,然后删除整个集合:
Call documentCollection.FTSearch("[Value] = Yes",0)
Call documentCollection.RemoveAll()
但要小心:FTSearch会减少收集量,根据数据库的FT索引设置->不太可靠,可能会得到“当然是”或“是”。小心:如果“do stuff”意味着删除文档,那么你的GetNextDocument行可能会失败,并出现“未设置对象变量”。。。在我的例子中,这就是“下一个”的原因……啊,是的,很好,托尔斯滕。不知怎的,我错过了MFG Flay想要删除文档,而不仅仅是处理/更新它们。谢谢你,亲爱的Per Henrik。小心:如果“do stuff”意味着删除文档,那么你的GetNextDocument行可能会失败,并出现“Object Variable not set”。。。在我的例子中,这就是“下一个”的原因……啊,是的,很好,托尔斯滕。不知何故,我错过了MFG Flay想要删除文档,而不仅仅是处理/更新它们。谢谢你,亲爱的Per Henrik。谢谢你的解释!我建议不要使用doc.Value引用该字段,而是使用doc.GetItemValue(“Value”)(0)。。。另外,doc.Value将返回一个变量,所以该行应该是这样的:如果doc.Value(0)=“Yes”,那么……真是太遗憾了!通常我从不使用直接访问。。。当然它必须是(0)。。。在我的回答中更正了这一点。谢谢你的解释!我建议不要使用doc.Value引用该字段,而是使用doc.GetItemValue(“Value”)(0)。。。另外,doc.Value将返回一个变量,所以该行应该是这样的:如果doc.Value(0)=“Yes”,那么……真是太遗憾了!通常我从不使用直接访问。。。当然它必须是(0)。。。在我的回答中更正了这一点。塔克斯