Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/database/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Database 访问VBA:Lotus Notes:选择Notes模板&;用Access中的数据填充_Database_Ms Access_Uiview_Vba_Lotus Notes - Fatal编程技术网

Database 访问VBA:Lotus Notes:选择Notes模板&;用Access中的数据填充

Database 访问VBA:Lotus Notes:选择Notes模板&;用Access中的数据填充,database,ms-access,uiview,vba,lotus-notes,Database,Ms Access,Uiview,Vba,Lotus Notes,我面临一个奇怪的问题:Access中有一个VBA脚本,它在单击按钮时以以下方式控制Lotus Notes: 连接并打开数据库 搜索某个模板 生成新邮件(在uiview中) 将数据填充到正文和主题中 将Lotus Notes带到前端 现在,如果用户在我的VBA表单中再次单击该按钮,则相同的过程会导致错误,如下所示: Set nMailDB = nSession.OpenDatabase(......) 结果是“什么都没有” 是否有任何方法可以获取Lotus Notes中当前打开的任何选项卡

我面临一个奇怪的问题:Access中有一个VBA脚本,它在单击按钮时以以下方式控制Lotus Notes:

  • 连接并打开数据库
  • 搜索某个模板
  • 生成新邮件(在uiview中)
  • 将数据填充到正文和主题中
  • 将Lotus Notes带到前端
现在,如果用户在我的VBA表单中再次单击该按钮,则相同的过程会导致错误,如下所示:

Set nMailDB = nSession.OpenDatabase(......) 
结果是“什么都没有”

是否有任何方法可以获取Lotus Notes中当前打开的任何选项卡的标题/名称或任何内容

Sub createNotesMail(frm As Form)
Dim nMailDb As Object
Dim nMailDoc As Object
Dim nMailTempDoc As Object
Dim nSession As Object
Dim nView As Object
Dim nWorkspace As Variant
Dim nCursor As Object
Dim nStationery As Object
Dim StationeryName As String

'Start Lotus Notes Session
Set nSession = CreateObject("Notes.NotesSession")
Set nMailDb = nSession.GetDatabase(NOTES_SERVER, NOTES_MAILIN)

' Open the Stationery View
Set nView = nMailDb.GetView("Stationery")
Set nWorkspace = CreateObject("Notes.NotesUIWorkspace")
Set nCursor = nView.GetFirstDocument

Do While Not nCursor Is Nothing
    ' get stationery value
    StationeryName = nCursor.GetItemValue("MailStationeryName")(0)
    ' match form template selection versus stationery
    If StationeryName = frm.TEMPLATE_NAME Then
        ' grab users signature from a temp UI document
        Set nMailTempDoc = nMailDb.CreateDocument
        Set nMailTempDoc = nWorkspace.Editdocument(True, nMailTempDoc)
        With nMailTempDoc
            .gotofield "Body"
            .SelectAll
            .Copy
            .Close
        End With

        ' create new document from stationery template, find and replace <PLACEHOLDERs>
        Set nMailDoc = nWorkspace.Editdocument(False, nCursor)
        With nMailDoc
            .gotofield "Body"
            .FINDSTRING "<SIGNATURE>"
            .Paste

            copyToClipboard frm.RECIPIENT
            .gotofield "Body"
            .FINDSTRING "<NAME>"
            .Paste

            copyToClipboard frm.DUEDATE
            .gotofield "Body"
            .FINDSTRING "<DUEDATE>"
            .Paste

            copyToClipboard frm.ORDERID
            .gotofield "Body"
            .FINDSTRING "<ORDERID>"
            .Paste

            Dim SubjectTemp As String
            SubjectTemp = .FIELDGETTEXT("Subject")
            SubjectTemp = Replace(SubjectTemp, "<ORDERID>", frm.ORDERID)
            SubjectTemp = Replace(SubjectTemp, "<DUEDATE>", frm.DUEDATE)
            .FIELDSETTEXT "Subject", SubjectTemp

            .FIELDSETTEXT "EnterSendTo", frm.RECIPIENT
        End With
        GoTo nMail_OK
    Else
        Set nCursor = nView.GetNextDocument(nCursor)
    End If
Loop

MsgBox "Error: Lotus Notes Template already opened or not found!"

nMail_OK:

Set nMailDb = Nothing
Set nMailDoc = Nothing
Set nMailTempDoc = Nothing
Set nSession = Nothing
Set nView = Nothing
Set nWorkspace = Nothing
Set nCursor = Nothing
Set nStationery = Nothing
End Sub
子createNotesMail(frm作为表单)
Dim nMailDb作为对象
Dim nMailDoc作为对象
Dim nMailTempDoc作为对象
作为对象的会话
作为对象的暗淡视图
Dim nWorkspace作为变体
作为对象的模糊轮廓
作为对象的Dim nStationery
Dim StationerName作为字符串
'启动Lotus Notes会话
Set nSession=CreateObject(“Notes.NotesSession”)
设置nMailDb=nSession.GetDatabase(NOTES\u服务器,NOTES\u邮件)
'打开“信纸”视图
设置nView=nMailDb.GetView(“信纸”)
设置nWorkspace=CreateObject(“Notes.NotesUIWorkspace”)
设置nCursor=nView.GetFirstDocument
不闻不问
'获取文具价值
StationeryName=nCursor.GetItemValue(“MailStationeryName”)(0)
'匹配表单模板选择与信纸
如果StationeryName=frm.TEMPLATE\u NAME,则
'从临时用户界面文档中获取用户签名
设置nMailTempDoc=nMailDb.CreateDocument
设置nmailEmpDoc=nWorkspace.Editdocument(True,nmailEmpDoc)
使用nmailempdoc
.Gotofeld“身体”
.全选
复制
关
以
'从信纸模板创建新文档,查找并替换
设置nMailDoc=nWorkspace.Editdocument(False,nCursor)
与nMailDoc
.Gotofeld“身体”
.FINDSTRING“”
粘贴
抄送剪贴板frm.RECIPIENT
.Gotofeld“身体”
.FINDSTRING“”
粘贴
复制到剪贴板frm.DUEDATE
.Gotofeld“身体”
.FINDSTRING“”
粘贴
copyToClipboard frm.ORDERID
.Gotofeld“身体”
.FINDSTRING“”
粘贴
将SubjectTemp设置为字符串
SubjectTemp=.FIELDGETTEXT(“主题”)
SubjectTemp=替换(SubjectTemp,“,frm.ORDERID)
SubjectTemp=替换(SubjectTemp,“,自到期日起)
.FIELDSETTEXT“主题”,SubjectTemp
.FIELDSETTEXT“EnterSendTo”,frm.RECIPIENT
以
转到nMail_好的
其他的
设置nCursor=nView.GetNextDocument(nCursor)
如果结束
环
MsgBox“错误:Lotus Notes模板已打开或找不到!”
正常:
设置nMailDb=Nothing
设置nMailDoc=Nothing
设置nmailempdoc=Nothing
设置nSession=Nothing
设置nView=Nothing
设置nWorkspace=Nothing
设置nCursor=Nothing
Set nStationery=无
端接头
如前所述:


我发现了一个可能的原因:如果我选择打开并用数据库中的数据填充的模板已经在Lotus Notes中打开,那么“MailStationeryName”是空的!一旦关闭模板,该值将返回到应该的值:

StationeryName = nCursor.GetItemValue("MailStationeryName")(0)
现在这对我有用了!我将扩展脚本以检查我的数据库使用的任何LotusNotes模板是否已打开,这意味着用户尚未完成任务

NOTES_SERVER and NOTES_MAILIN are CONSTs declared elsewhere.

据我所知,这是由Notes管理的。您是否关闭按钮末尾的便笺会话?也许有些东西被回收了?更多代码更多帮助:-)