[英]Booking Appointments in A Public Calendar in outlook Using VBA/Excel
I was just wondering if anyone can help me. 我只是想知道是否有人可以帮助我。 I am very new to coding and am trying to create a macro that books full day events in a shared outlook calendar.
我对编码非常陌生,正在尝试创建一个宏,以在共享Outlook日历中预订全天活动。 I have searched the depths of the internet and cant seem to find anything.
我搜索了互联网的深度,似乎找不到任何东西。
I am trying to use the below code which picks up the from and to date in a range on the work book and book into the following shared calendar "\\UK Public Folders\\Customer Services\\UK Customer Services Calendar" in outlook but I am just not having any luck defining the folder path. 我正在尝试使用下面的代码来提取工作簿中某个范围的起止日期和截止日期,并将其预订到Outlook中的以下共享日历“ \\ UK Public Folders \\ Customer Services \\ UK Customer Services Calendar”中,但是我只是没有定义文件夹路径的运气。 can anyone help?
有人可以帮忙吗?
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
any help would be greatly appreciated 任何帮助将不胜感激
many thanks 非常感谢
Jamie 杰米
What is the error code or error message? 错误代码或错误消息是什么? Are you using On Error Resume Next to hide error messages?
您是否使用On Error Resume Next隐藏错误消息? Do not!
不要!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.