在Outlook的ThisOutlookSession中,写入代码,并引用Excel对象。(以下代码结合了chijanzen的代码)。再把源数据文件保存为E:\OL_Reminder.xls。 Option Explicit Private Sub Application_Startup() CreateNewAM End Sub
Private Sub CreateNewAM() Dim XL_app As Excel.Application Dim XL_wb As Excel.Workbook Dim OLAitem As Outlook.AppointmentItem Dim Bodytxt As String Dim i As Integer Set XL_app = CreateObject("Excel.Application") Set XL_wb = XL_app.Workbooks.Open("E:\OL_Reminder.xls") Bodytxt = "今天到期生產單號" & Chr(10) i = 9 With XL_app.Workbooks("OL_Reminder.xls").Sheets(2) Do While .Cells(i, 9) <> "" If CDate(.Cells(i, 9)) = Date Then Bodytxt = Bodytxt & .Cells(i, "B") & Chr(10) End If i = i + 1 Loop End With On Error GoTo 0 Set OLAitem = CreateItem(olAppointmentItem) '工作 On Error Resume Next With OLAitem .Subject = "今天到期的工作" .Start = Now .End = Now .ReminderMinutesBeforeStart = 30 '30分鐘前提醒 .Body = Bodytxt .Save .Display End With XL_app.ActiveWorkbook.Saved = True XL_app.Workbooks.Close Set XL_app = Nothing End Sub
[此贴子已经被作者于2006-6-29 14:23:05编辑过] |