|
楼主 |
发表于 2010-2-2 13:52
|
显示全部楼层
我的OUTLOOK里面的VBA如下
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 Bodytxt1, Bodytxt2, Bodytxt3, Bodytxt4 As String
Dim i As Integer
Set XL_app = CreateObject("Excel.Application")
Set XL_wb = XL_app.Workbooks.Open("C:\Documents and Settings\chenqx\Desktop\CPE\Polycom IP Phone warranty.xls")
Bodytxt1 = "These IP Phones need to extend the warranty" & Chr(10)
Bodytxt2 = "Customer: "
Bodytxt3 = "IP Phone Model: "
Bodytxt4 = "Warranty Expire on: "
i = 67
With XL_app.Workbooks("Polycom IP Phone warranty.xls").Sheets(1)
Do While .Cells(i, 9) <> ""
If CDate(.Cells(i, 9)) - Date <= 90 Then
Bodytxt1 = Bodytxt1 & Bodytxt2 & .Cells(i, "B") & Chr(32) & Chr(32) & Chr(32) & Chr(32) & Bodytxt3 & .Cells(i, "D") & Chr(32) & Chr(32) & Chr(32) & Chr(32) & Bodytxt4 & .Cells(i, "I") & 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 = "IP Phone Warranty Alarm"
.Start = Now
.End = Now
.ReminderMinutesBeforeStart = 30
.Body = Bodytxt1
.Save
.Display
End With
XL_app.ActiveWorkbook.Saved = True
XL_app.Workbooks.Close
Set XL_app = Nothing
End Sub |
|