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

Create an appointment with required attendees in Lotus Notes using VBA in Access 2013

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

Run-time error '-2147417851 (80010105)': Automation error. The server threw an exception.

除尝试添加与会者的部分外,其他一切正常。我知道 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 = "User1@company.com" Then
CalenDoc.FIELDSETTEXT "RequiredAttendees", "User2@company.com" & "," & "User3@company.com"
CalenDoc.Refresh
ElseIf EmailAddress = "User2@company.com" Then
CalenDoc.FIELDSETTEXT "RequiredAttendees", "User1@company.com" & "," & "User3@company.com"
CalenDoc.Refresh
ElseIf EmailAddress = "User3@company.com" Then
CalenDoc.FIELDSETTEXT "RequiredAttendees", "User2@company.com" & "," & "User1@company.com"
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

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

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

由于您使用的是 OLE,因此需要在 "EnterSendTo" 字段中输入数据。实际上,您(或用户)放入其中的数据最终会出现在 RequiredAttendees 项中,这是因为与约会表单关联的公式和脚本中发生了魔法。