【发布时间】:2021-01-30 18:53:14
【问题描述】:
代码停止运行并突出显示 .Body = "" 并说它是无效或不合格的 参考。非常感谢任何见解。
注意,以Appt_开头的变量都是在另一个模块中定义的全局变量。
Sub RegisterAppointmentList(CName As String)
' adds a list of appontments to the Calendar in Outlook
Dim olApp As Outlook.Application
Dim olAppItem As Outlook.AppointmentItem
Set olAppItem = Application.CreateItem(olAppointmentItem)
On Error Resume Next
Set olApp = GetObject("", "Outlook.Application")
On Error GoTo 0
If olApp Is Nothing Then
On Error Resume Next
Set olApp = CreateObject("Outlook.Application")
On Error GoTo 0
If olApp Is Nothing Then
MsgBox "Outlook is not available!"
Exit Sub
End If
End If
olAppItem _
.Location = ""
.Body = ""
.Start = Nothing
.End = Nothing
.ReminderSet = True
.ReminderMinutesBeforeStart = 15
.BusyStatus = olFree
.RequiredAttendees = "jerry@1sba.com"
On Error Resume Next
.Start = Appt_STime
.End = Appt_ETime
.Subject = CName & "," & Appt_Subject
.Location = Appt_Location
.Body = Appt_Description
.ReminderSet = True
.BusyStatus = olBusy
On Error GoTo 0
.Save ' saves the new appointment to the default folder
Set olAppItem = Nothing
Set olApp = Nothing
MsgBox "Done !"
End Sub
【问题讨论】:
-
您缺少
with和end with声明。
标签: excel vba appointment