Excel 在特定日期前30天创建Outlook约会
我已经设置了一些代码来创建Outlook约会,尽管我试图将开始时间设置为G列(I,7)单元格中任何日期之前的30天 有没有办法做到这一点,或者我只需要在Excel中添加一个额外的列,其中包含此日期Excel 在特定日期前30天创建Outlook约会,excel,vba,outlook,Excel,Vba,Outlook,我已经设置了一些代码来创建Outlook约会,尽管我试图将开始时间设置为G列(I,7)单元格中任何日期之前的30天 有没有办法做到这一点,或者我只需要在Excel中添加一个额外的列,其中包含此日期 Option Explicit Option Compare Text 'ignore case sensitivity when comparing strings Sub EventsReminders() Dim OL As Outlook.Application, ES As Wo
Option Explicit
Option Compare Text 'ignore case sensitivity when comparing strings
Sub EventsReminders()
Dim OL As Outlook.Application, ES As Worksheet, _
r As Long, i As Long, wb As ThisWorkbook
Set wb = ThisWorkbook
Set ES = wb.Sheets("Events")
Set OL = New Outlook.Application
r = ES.Cells(Rows.Count, 1).End(xlUp).Row
For i = 8 To r
With ES.Cells(i, 2)
If .Value = "Yes" And ES.Cells(i, 3) <> "Yes" Then
ES.Cells(i, 3) = "Yes"
With OL.CreateItem(olAppointmentItem)
.Subject = "Raise works order"
.Start = ES.Cells(i, 7) + TimeValue("09:00:00")
.ReminderSet = True
.ReminderMinutesBeforeStart = 60
.Body = ES.Cells(i, 5).Value + "_" + ES.Cells(i, 9).Value
.Save
End With
End If
End With
Next i
Set OL = Nothing
Set wb = Nothing
Set ES = Nothing
End Sub
选项显式
选项“比较文本”在比较字符串时忽略区分大小写
子事件提醒者()
Dim OL作为Outlook.Application,ES作为工作表_
r一样长,i一样长,wb一样长
设置wb=ThisWorkbook
设置ES=wb.Sheets(“事件”)
Set OL=New Outlook.Application
r=ES.单元格(Rows.Count,1).End(xlUp).Row
对于i=8到r
有ES.细胞(i,2)
如果.Value=“Yes”和ES.Cells(i,3)“Yes”,则
ES.单元格(i,3)=“是”
使用OL.CreateItem(olAppointmentItem)
.Subject=“提出工程订单”
.Start=ES.Cells(i,7)+时间值(“09:00:00”)
.提醒集=真
.ReminderMinutesBeforeStart=60
.Body=ES.Cells(i,5).Value+“”+ES.Cells(i,9).Value
拯救
以
如果结束
以
接下来我
设置OL=无
设置wb=Nothing
设置ES=无
端接头
假设G列包含实际日期,而不是表示日期的文本,请尝试:
.Start = ES.Cells(i, 7) - 30 + TimeValue("09:00:00")