微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

使用Excel VBA在Outlook中创建提醒

如何解决使用Excel VBA在Outlook中创建提醒

试图创建从Excel到Outlook的提醒。我需要将它们发送整整一周的时间,因为该任务将在一周的每一天重复进行,因此我将在周一,周二等提醒您-尚未知道。到目前为止,它只发送了一天,但是我的代码并不出色,它只发送了一个,而没有发送我要为其创建提醒的所有项目。我也有几个类别,每个类别将包含不同数量的任务,例如下面示例中的类别1包含5个项目,但是类别2仅包含3个项目,而类别3包含10个项目

我的数据表

enter image description here

我的代码

Option Explicit
Public Sub CreateOutlookAppointments()
Sheets("Reminders").Select
On Error GoTo Err_Execute

   Dim olApp As outlook.application
Dim olAppt As Outlook.AppointmentItem
Dim blnCreated As Boolean
Dim olNs As Outlook.Namespace
Dim CalFolder As Outlook.MAPIFolder
Dim arrCal As String

 
Dim i As Long

On Error Resume Next
Set olApp = outlook.application

If olApp Is nothing Then
    Set olApp = outlook.application
     blnCreated = True
    Err.Clear
Else
    blnCreated = False
End If

On Error GoTo 0

Set olNs = olApp.GetNamespace("MAPI")
Set CalFolder = olNs.GetDefaultFolder(olFolderCalendar)
   
Dim LastRow As Long
LastRow = Cells(Rows.Count,19).End(xlUp).Row

For i = 6 To LastRow
If IsDate(Cells(i,19)) And UCase(Trim(Cells(i,21))) <> "ADDED" Then

arrCal = Cells(i,6)
Set olAppt = CalFolder.Items.Add(olAppointmentItem)

'MsgBox subFolder,vbOKCancel,"Folder Name"

With olAppt

'Define calendar item properties
    .Start = Cells(i,19) + Cells(i,20)
    .End = Cells(i,21) + Cells(i,22)
    .Subject = Cells(i,15)
    .Location = Cells(i,16)
    .Body = Cells(i,17)
    .BusyStatus = olBusy
    .ReminderMinutesBeforeStart = Cells(i,23)
    .ReminderSet = True
    .Categories = Cells(i,18)
    .Save
' For meetings or Group Calendars
 ' .Send
End With
   Cells(i,21) = "Added"

End If

Next


Exit Sub

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?