为什么我会通过 AppointItem 获得无效或不合格的参考资料?
Why would I get an Invalid or unqualified reference part way through an AppointItem?
代码停止 运行 .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”:
With 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
End With
代码停止 运行 .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”:
With 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
End With