我在Excel文件中使用了JavaScript代码。
我想额外的代码发送一个经常性的电子邮件提醒,如果文件没有在14天内保存。
Sub SEND_Colleague()
Dim MyFile As String
MyFile = ActiveWorkbook.Name
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:= & MyFile
Set OutlookApp = CreateObject("Outlook.Application")
Set OutlookMail = OutlookApp.CreateItem(0)
On Error Resume Next
On Error GoTo 0
With OutlookMail
.to = "[email protected]"
.Importance = 2
.Subject = ActiveWorkbook.Name
If InStr(Filename, ".") > 0 Then
End If
.HTMLbody = "<html><body><p><font size=4>My Colleague: <p></p>" _
& "</p><p>Please navigate to the tracking log named in the subject line of this email by clicking the link below and update the <b><i>Product</i></b> section of the log. <p></p>" _
& "Once your updates are entered, click the form control button in <b>Cell B61</b>. The workbook will be saved to the Network shared folder and closed automatically. Thereafter, the Outlook mail program will be initiated and a pop-up warning message will appear. Click <u><b>Allow</b></u> and an email will be sent to the area leader. A copy of the email can be found in your Outlook <i>Sent</i> folder.<p>" _
& "</p><p><b><FONT COLOR=red>Note, you must return to this log and follow the steps above every 14 days until all thrid-party claims are fully adjudicated. </p></b><FONT COLOR=black>" _
& "</p><p>Thank You</p>" _
.SEND
End With
Set OutlookMail = Nothing
Set OutlookApp = Nothing
ActiveWorkbook.Close
End Sub
1条答案
按热度按时间ctehm74n1#
您需要检查上次编辑日期是否大于14天。
您可以使用
ThisWorkbook.BuiltInDocumentProperties
访问工作簿的信息,它将返回文件属性的集合。最后修改的日期应该有索引12。然后,存储文件的上次修改日期的值:然后将该日期与今天的日期进行比较(如果您愿意,还可以使用时间,因为
ThisWorkbook.BuiltinDocumentProperties(12)
也包含时间信息)。