Retrieving NotesDocumentCollection during QueryPaste

北战南征 提交于 2021-01-29 09:13:50

问题


Is this possible in Notes? I am currently using version 11. I have a form with an embedded view in it. This view has code in the QueryPaste function. For example it has the code:

Sub Querypaste(Source As Notesuiview, Continue As Variant)
    Dim ndcRegel As NotesDocumentCollection
    Dim docRegel As NotesDocument

    Set ndcRegel = source.Documents
    Msgbox "1"
    Msgbox source.Documents.Count
    etc...

When copy and pasting a document in the embedded view, it triggers Msgbox 1 first and then for the count I get the result 0. While there are documents in the embedded view.

When I am copy pasting in the view itself then it correctly works and does find a ndc collection..

Why is this so? And can this be fixed? Because I want to block my users to copy paste documents in an embedded view.


回答1:


Documents copied in the Notes client are placed in a local database with the file name "~clipbrd.ncf".
I can't remember where I found this information, but it was somewhere on the internet.

In a view's QueryPaste event, you can get that database, and its AllDocuments property contains the documents to be pasted.

I've only used this with Notes 8.5.x and 9.0.x clients, and for views which are not embedded, so make sure to test before relying on it.

Example code:

Sub Querypaste(Source As Notesuiview, Continue As Variant)
    Dim clipDb As New NotesDatabase("","~clipbrd.ncf")
    Dim dc As NotesDocumentCollection

    Set dc=clipDb.AllDocuments
    ' dc now contains copied documents.
End Sub



回答2:


@Teleman's comment was going to be my reaction, but QueryPaste is only defined for the view, not for the form or for the embedded view. At least that's true in R9, anyhow.

In any case, the source parameter for QueryPaste is a NotesUIView object, and the Documents property is defined as the collection containing the selected documents, and I suspect that during a paste operation there are, effectively, no selected documents. In fact, the documentation says this:

In the QueryPaste event, Documents does not contain a list of the documents being pasted. You can use the Documents property in the Postpaste event to access thelist after the documents are pasted, or you can create an agent to process pasted documents.



来源:https://stackoverflow.com/questions/62147353/retrieving-notesdocumentcollection-during-querypaste

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!