标题说明了一切。我昨天写了代码,它运行良好。我是个白痴,错误地保存并丢失了代码。但是,今天我重写了代码以实现它,我不确定为什么今天没有创建约会。当我通过我的 Sub 进行 F8 时,这些值被正确存储。如果有人能指出我忽略的那个愚蠢的错误,那将是一个救命稻草,因为我自己找不到它。
Sub test()
Dim OL As Outlook.Application, Appoint As Outlook.AppointmentItem, ES As Worksheet, _
r As Long, i As Long, WB As ThisWorkbook
Set WB = ThisWorkbook
Set ES = WB.Sheets("Export Sheet")
r = ES.Cells(Rows.count, 1).End(xlUp).Row
Set OL = New Outlook.Application
For i = 2 To r
Set Appoint = OL.CreateItem(olAppointmentItem)
With Appoint
.Subject = ES.Cells(i, 1).Value
.Start = ES.Cells(i, 2).Value
.End = ES.Cells(i, 3).Value
.Location = ES.Cells(i, 4).Value
.AllDayEvent = ES.Cells(i, 5).Value
.Categories = ES.Cells(i, 6).Value & " Category"
End With
Next i
Set OL = Nothing
End Sub