我正在尝试设置 VBS 以在按下命令按钮时在特定日历(非默认(中创建会议。我的代码有效,但在默认日历中创建会议。我试过玩弄它,但我是 VBS(主要使用 VBA(的新手。我知道 VBA 和 VBS 是相似的,所以我确定必须调整一些小东西。我希望将会议放在名为"测试"的日历中,该日历位于"我的日历"下。
Sub commandbutton1_Click()
If CommandButton1 = False Then
Dim objOL 'As Outlook.Application
Dim objAppt 'As Outlook.AppointmentItem
Const olAppointmentItem = 1
Const olMeeting = 1
Const olFree = 0
Set objOL = CreateObject("Outlook.Application")
Set objAppt = objOL.CreateItem(olAppointmentItem)
objAppt.Subject = "My Test Appointment"
objAppt.Start = #8/24/17 3:50:00 PM#
objAppt.Duration = 1
objAppt.Location = "Followup"
objAppt.Body = "Test Verbiage"
objAppt.ReminderMinutesBeforeStart = 1
objAppt.BusyStatus = olFree
objAppt.Save()
Set objAppt = Nothing
Set objOL = Nothing
End If
End Sub
试试这个:
Sub commandbutton1_Click()
If CommandButton1 = False Then
Const olAppointmentItem = 1
Const olMeeting = 1
Const olFree = 0
Set objOutlook = CreateObject("Outlook.Application")
Set objNamespace = objOutlook.GetNamespace("MAPI")
Set objDictionary = CreateObject("Scripting.Dictionary")
objDictionary.Add "August 24, 2017", "My Test Appointment"
colKeys = objDictionary.Keys
For Each strKey in colKeys
dtmApptDate = strKey
strApptName = objDictionary.Item(strKey)
Set objAppt = objOutlook.CreateItem(olAppointmentItem)
objAppt.Subject = strApptName
objAppt.Start = dtmApptDate & " 3:50 PM"
objAppt.Duration = 1
objAppt.Location = "Followup"
objAppt.Body = "Test Verbiage"
objAppt.ReminderSet = True
objAppt.ReminderMinutesBeforeStart = 1
objAppt.AllDayEvent = True
objAppt.BusyStatus = olFree
objAppt.Save
Next
End If
End Sub