使用Access 2013中的VBA在Lotus Notes中创建所需与会者的约会

问题描述 投票:0回答:1

我正在尝试在Access 2013中为库存创建签出日志。在此过程中,您将在Lotus Notes 9日历中的预期返回日期创建约会。我找到了足够的例子来成功地做到这一点。但是,在尝试将人员添加到“RequiredAttendees”字段时,我遇到了困难。我很确定我使用正确的字段名称,但我不断收到以下错误:

运行时错误'-2147417851(80010105)':自动化错误。服务器抛出异常。

除了尝试添加与会者的部分之外,其他所有工作正常。我知道Lotus Notes 9已经老了,我知道Access 2013已经过时了,但这些是我需要使用的工具。任何帮助,将不胜感激。

Public Function test() As Variant

Dim StartTime As Date
Dim MailDbName As String
Dim CalenDoc As Object
Dim WorkSpace As Object
Dim AppDate As String
Dim AppTime As String
Dim Subject As String

Set WorkSpace = CreateObject("Notes.NOTESUIWORKSPACE")

AppDate = InputBox(Prompt:="Enter the return date:")
'Subject = InputBox(Prompt:="Enter the subject:")
'AppTime = InputBox(Prompt:="Enter the time:")

MailDbName = "mail\User.nsf"

strSTime = CStr(Timex)

Set CalenDoc = WorkSpace.COMPOSEDOCUMENT("MailServer", MailDbName, "Appointment")
CalenDoc.FIELDSETTEXT "AppointmentType", "3"
CalenDoc.Refresh

CalenDoc.FIELDSETTEXT "StartDate", CStr(AppDate)
CalenDoc.FIELDSETTEXT "EndDate", CStr(AppDate)
CalenDoc.FIELDSETTEXT "StartTime", "12:00 PM"
CalenDoc.FIELDSETTEXT "EndTime", "12:00 PM"
CalenDoc.FIELDSETTEXT "Subject", "Test"

GetUser = Environ("UserName")
EmailAddress = GetUser & "@company.com"

If EmailAddress = "[email protected]" Then
CalenDoc.FIELDSETTEXT "RequiredAttendees", "[email protected]" & "," & "[email protected]"
CalenDoc.Refresh
ElseIf EmailAddress = "[email protected]" Then
CalenDoc.FIELDSETTEXT "RequiredAttendees", "[email protected]" & "," & "[email protected]"
CalenDoc.Refresh
ElseIf EmailAddress = "[email protected]" Then
CalenDoc.FIELDSETTEXT "RequiredAttendees", "[email protected]" & "," & "[email protected]"
CalenDoc.Refresh
Else
MsgBox (EmailAddress & "is not a valid email address.")
End If


'CalenDoc.gotoField "Body"
'CalenDoc.InsertText Body
CalenDoc.Refresh
'CalenDoc.Save
'CalenDoc.Close
'Set CalenDoc = Nothing
'Set WorkSpace = Nothing
vba calendar lotus-notes ms-access-2013
1个回答
2
投票

我认为通过查看使用后端COM类的示例而不是使用前端OLE类的示例,或者除了使用前端OLE类的示例之外,我认为您已经感到困惑。您正在使用Notes.NOTESUIWORKSPACE - OLE,而不是Lotus.NotesSession - COM。这意味着您必须使用约会表单上的实际可编辑字段,这有时不是您期望的那样。在某些情况下,这些前端字段与最终存储在后端文档中的项目不同 - 它是通常记录的后端项目名称,因为它们是存储在后端的项目名称那个笔记。

RequiredAttendees是存储的项目名称,但是您收到自动化错误,因为它是约会表单上的计算字段,而不是可编辑字段。

由于您使用的是OLE,因此需要将数据输入“EnterSendTo”字段。事实上,您(或用户)放入的数据最终会出现在RequiredAttendees项中,因为与约会表单关联的公式和脚本中存在魔力。

© www.soinside.com 2019 - 2024. All rights reserved.