NotesUIWorkspace.EditDocument有时不返回任何内容

时间:2014-01-08 09:53:18

标签: excel vba excel-vba lotus-notes

我正在编写一个vba sub,允许用户根据excel电子表格中的内容发送Lotus Notes电子邮件。

以下子程序有时会运行没有问题,但有时会在最后

附近失败
Set uiDoc = uiws.EditDocument(True, oDoc)

其中Lotus Notes应用程序UI显然打开了一个新邮件进行编辑,但变量uiDoc没有收到NotesUIDocument实例。

这个问题对我来说似乎是随机的,我现在通过多次手动重新运行sub来解决这个问题,直到它成功为止。

我如何确保uiDoc获取实例?

Public Sub SendEmail( _
    Ws As Worksheet, _
    Optional Commit As Boolean = False, _
    Optional Delim As String = "<Delim>")

    ' Notes session
    Dim oSess As Object
    Set oSess = CreateObject("Notes.NotesSession")


    ' Notes database
    Dim oDB As Object
    Set oDB = oSess.GETDATABASE("", "")
    If Not oDB.IsOpen Then
        oDB.OPENMAIL
    End If


    ' Notes documment
    Dim oDoc As Object
    Set oDoc = oDB.CREATEDOCUMENT

    oDoc.Subject = Ws.Range("Subject").Value

    Dim VSendTo As Variant
    VSendTo = Split(Ws.Range("Send_To").Value, ",")
    oDoc.sendto = VSendTo

    Dim VCCTo As Variant
    VCCTo = Split(Ws.Range("CC_To").Value, ",")
    oDoc.copyto = VCCTo

    Dim oItem As Object
    Set oItem = oDoc.CREATERICHTEXTITEM("BODY")


    ' Notes UI document
    Dim uiws As Object
    Set uiws = CreateObject("Notes.NotesUIWorkspace")

    Dim uiDoc As Object
    ' uiDoc should receive a NotesUIDocument if successful
    Set uiDoc = uiws.EditDocument(True, oDoc)


    ' Body
    DoEvents

    Call uiDoc.GOTOFIELD("Body")

    ' ** Omitted **

Exit Sub

NotesUIWorkspace类的文档: http://publib.boulder.ibm.com/infocenter/domhelp/v8r0/topic/com.ibm.designer.domino.main.doc/H_NOTESUIWORKSPACE_CLASS.html

我正在使用Lotus Notes V8.5.2

0 个答案:

没有答案