【发布时间】:2015-01-12 19:49:51
【问题描述】:
我不是编码员,对 VBA 或脚本的基本知识基础还不够。我将这段代码拼凑在一起,它将获取一个 Excel 电子表格(每行一个会议)并生成一个包含主题、日期/时间和与会者的日历邀请。此约会项正在我的日历上生成,但我需要在我的共享日历上打开它。警告:我不知道执行此操作需要什么代码,而且我不知道 Outlook 日历路径的格式。这些帐户链接到我的公司服务器,我们在全局目录中使用别名.
Sub AddAppointments()
Dim myoutlook As Object ' Outlook.Application
Dim r As Long
Dim myapt As Object ' Outlook.AppointmentItem
' late bound constants
Const olAppointmentItem = 1
Const olBusy = 2
Const olMeeting = 1
' Create the Outlook session
Set myoutlook = CreateObject("Outlook.Application")
' Start at row 2
r = 2
Do Until Trim$(Cells(r, 1).Value) = ""
' Create the AppointmentItem
Set myapt = myoutlook.CreateItem(olAppointmentItem)
' Set the appointment properties
With myapt
.Subject = Cells(r, 1).Value
.Location = Cells(r, 2).Value
.Start = Cells(r, 3).Value
.Duration = Cells(r, 4).Value
'.Recipients.Add Cells(r, 8).Value
' **Why Doesn't this Work?!?**
.Recipients.ResolveAll
.MeetingStatus = olMeeting
' not necessary if recipients are email addresses
.AllDayEvent = Cells(r, 31).Value
' If Busy Status is not specified, default to 2 (Busy)
If Len(Trim$(Cells(r, 5).Value)) = 0 Then
.BusyStatus = olBusy
Else
.BusyStatus = Cells(r, 5).Value
End If
If Cells(r, 6).Value > 0 Then
.ReminderSet = True
.ReminderMinutesBeforeStart = Cells(r, 6).Value
Else
.ReminderSet = False
End If
'Set body format to HTML - ** THIS DOESN'T WORK **
'.BodyFormat = olFormatHTML
'.HTMLBody = "<HTML><BODY>Enter the message text here. </BODY></HTML>"
.Body = Cells(r, 7).Value
.Save
r = r + 1
.Send
End With
Loop
End Sub
【问题讨论】:
标签: vba excel calendar outlook-addin