使用uidoc.copy时,文档命令不可用

时间:2012-03-09 18:28:37

标签: lotus-notes lotusscript

当程序到达uidoc.Copy行时,我收到错误'文档命令不可用'。我研究过这个错误信息。但我得到的只是它与编辑模式有关,而我根本就没有使用它。

    Sub Click(Source As Button)

' ===========================================================
' Get common username, mail server, and mailfile information 
  to be used on ComposeDocument method

    Dim session As New NotesSession
    Dim reg As New NotesRegistration
    Dim user As String

    reg.RegistrationServer = "Test"
    user = session.CommonUserName
    Call reg.GetUserInfo(user, _
    mailserver$, _
    mailfile$)
' ======================================================================    
    Dim workspace As New NotesUIWorkspace
    Dim uidoc As NotesUIDocument
    Set uidoc = workspace.CurrentDocument

    Call uidoc.GotoField("QSContactEMail")
    Call uidoc.SelectAll
    Call uidoc.Copy

    Set uidoc = workspace.ComposeDocument _
    (mailserver$, mailfile$, "Memo")
    Call uidoc.GotoField("Subject")
    Call uidoc.Paste
    End Sub

2 个答案:

答案 0 :(得分:1)

您不需要使用复制和粘贴功能将值从一个文档传输到另一个文档。您可以使用文档对象直接分配这些值。

有几种方法可以做到这一点 - 这里有一个类似于你的方法。用这个替换第二行下面的所有内容:

Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument, newuidoc as NotesUIDocument

Set uidoc = workspace.CurrentDocument
Set newuidoc = workspace.ComposeDocument _
(mailserver$, mailfile$, "Memo")

Call newuidoc.FieldSetText("Subject", uidoc.FieldGetText("QSContactEMail"))

End Sub

答案 1 :(得分:0)

检查是否有一个名为$ KeepPrivate的字段设置为“1”。它会阻止复制。

如果未选择任何内容,也会发生错误。尝试在行前停止并确保突出显示。

此处还列出了其他条件:

http://www-01.ibm.com/support/docview.wss?uid=swg21094450