我正在尝试设置VBS,以便在按下命令按钮时在特定日历(非默认)中创建会议。我可以使用的代码,但在默认日历中创建会议。我试过去玩弄它,但我是VBS的新手(主要用于VBA)。我知道VBA和VBS是相似的,所以我确定一些小的东西必须调整。我希望将会议放在名为Test的日历中,该日历位于My Calendars下。
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
答案 0 :(得分:0)
试试这个:
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