0
我只是想知道是否有人可以幫助我。我對編碼非常陌生,並且試圖創建一個在共享Outlook日曆中預訂全天事件的宏。我搜索了互聯網的深度,似乎找不到任何東西。使用VBA/Excel在Outlook中公開日曆中預約約會
我正嘗試使用下面的代碼,它將工作簿中的一個範圍內的日期和日期記錄到Outlook中的以下共享日曆中:「\ UK Public Folders \ Customer Services \ UK Customer Services Calendar」但我只是沒有任何運氣定義文件夾路徑。誰能幫忙?
Option Explicit
Sub CreateOutlookAppointment()
Dim strCategory As String, strTopic As String, strLocation As String, strStartdate As String, strStarttime As String
Dim strEnddate As String, strEndtime As String, strDuration As String, bolWholeday As Boolean, bolReminder As Boolean, lngReminderMinutes As Long
Dim bolPlaysound As Boolean, strParticipants As String, bolRespondNecessary As Boolean, strNote As String
Dim strCategory As String, strTopic As String, strLocation As String, strStartdate As String, strStarttime As String
Dim strEnddate As String, strEndtime As String, strDuration As String, bolWholeday As Boolean, bolReminder As Boolean, lngReminderMinutes As Long
Dim bolPlaysound As Boolean, strParticipants As String, bolRespondNecessary As Boolean, strNote As String
Dim olApp As Object
Dim objCal As Object
Dim olCal As Object
Set olApp = CreateObject("Outlook.Application")
Set objCal = olApp.Session.GetDefaultFolder(9)
Set olCal = objCal.Items.Add(1)
'=============================================================
'Entries for appointment
'=============================================================
strCategory = "Holiday"
strTopic = Range("Employee3")
strLocation = ""
strStartdate = Range("FROM1")
strStarttime = "09:00"
strEnddate = Range("FROM2")
strEndtime = "09:00"
strDuration = "60" 'If duration of appointment necessary, remove comment for "Duration" below
bolWholeday = True
bolReminder = True
lngReminderMinutes = 10
bolPlaysound = True
strParticipants = Range("A8").Value
bolRespondNecessary = False
strNote = "Your On Holiday"
'=============================================================
'Create appointment
With olCal
.Categories = strCategory
.Subject = strTopic
.Location = strLocation
.Start = strStartdate & " " & strStarttime
.End = strEnddate & " " & strEndtime
'.Duration = strDuration 'If duration is given about, remove comment
.AllDayEvent = bolWholeday
.ReminderSet = bolReminder
.ReminderMinutesBeforeStart = lngReminderMinutes
.ReminderPlaySound = bolPlaysound
.Recipients.Add strParticipants
.ResponseRequested = bolRespondNecessary
.Body = strNote
.Display
End With
On Error Resume Next
Set olCal = Nothing
Set olApp = Nothing
End Sub
任何幫助,將不勝感激
千恩萬謝
傑米
運行時沒有任何反應,並且沒有錯誤後彈出。我試圖調試它,但它只是通過代碼運行。所以不能弄清楚我做錯了什麼。由於編碼方面的經驗不足,我不知道從哪裏開始 –
好吧,在開始後的某個地方設置一個斷點(F9)。點擊時,使用F8瀏覽代碼。 – peakpeak