跳到主要内容

如何在Outlook日历上按生日计算和显示年龄?

一般来说,联系人的生日会自动添加为日历中的年度定期约会。 但是您知道如何计算联系人的年龄并直接在日历视图中显示该年龄吗? 本文将介绍一个VBA,以计算每个联系人的年龄,并在Outlook中显示相对定期约会主题的年龄。

在Outlook日历上按生日计算并显示年龄

Office 选项卡 - 在 Microsoft Office 中启用选项卡式编辑和浏览,让工作变得轻而易举
Kutools for Outlook - 通过 100 多个高级功能增强 Outlook,实现卓越效率
使用这些高级功能增强您的 Outlook 2021 - 2010 或 Outlook 365。 享受全面的 60 天免费试用并提升您的电子邮件体验!

箭头蓝色右气泡在Outlook日历上按生日计算并显示年龄

要计算每个联系人的年龄并在Outlook日历中显示相对重复约会主题中的年龄,请执行以下操作:

1。 打开默认的日历文件夹,然后按 其他 + F11 键以打开“ Microsoft Visual Basic应用程序”窗口。

2。 点击 插页 > 模块,然后将以下VBA代码粘贴到新的模块窗口中。

VBA:在Outlook日历中计算并显示联系人的年龄

Option Explicit
Public Sub UpdateAges()
Dim xOlApp As Outlook.Application
Dim xOlFolder As Outlook.Folder
Dim xOlItems As Outlook.Items
Dim xAppointmentItem As AppointmentItem
Dim xAge As Integer
Dim xOlProp As Outlook.UserProperty
Set xOlApp = Outlook.Application
Set xOlFolder = Session.GetDefaultFolder(olFolderCalendar)
Set xOlItems = xOlFolder.Items
For Each xAppointmentItem In xOlItems
If (InStr(1, xAppointmentItem.Subject, "Birthday") Or InStr(1, xAppointmentItem.Subject, "Anniversary")) And xAppointmentItem.IsRecurring = True Then
With xAppointmentItem
If xAppointmentItem.UserProperties("Original Subject") Is Nothing Then
Set xOlProp = xAppointmentItem.UserProperties.Add("Original Subject", olText, True)
xOlProp.Value = .Subject
.Save
End If
xAge = DateDiff("yyyy", .Start, Date)
.Subject = .UserProperties("Original Subject") & " (" & xAge & " in " & Format(Date, "yyyy") & ")"
.Save
End With
End If
Next
Set xAppointmentItem = Nothing
Set xOlItems = Nothing
Set xOlFolder = Nothing
Set xOlApp = Nothing
End Sub

3。 按 F5 键或 运行 按钮以运行此VBA。

当您返回默认日历时,您会看到每个联系人的年龄都已确定并显示在定期生日约会的主题中。 看截图:

:
(1)对于某位联系人的定期生日约会,该联系人的年龄包含在括号中,类似于 (41中的2017), 41 是年龄,并且 2017 是当前年份。
(2)如果您在联系人文件夹中更改某个联系人的生日,则年龄将从日历中自动删除。
(3)此VBA仅适用于默认的Outlook日历。


箭头蓝色右气泡相关文章


最佳办公生产力工具

Kutools for Outlook - 超过 100 种强大功能可增强您的 Outlook

🤖 人工智能邮件助手: 具有人工智能魔力的即时专业电子邮件——一键天才回复、完美语气、多语言掌握。轻松改变电子邮件! ...

📧 电子邮件自动化: 外出(适用于 POP 和 IMAP)  /  安排发送电子邮件  /  发送电子邮件时按规则自动抄送/密件抄送  /  自动转发(高级规则)   /  自动添加问候语   /  自动将多收件人电子邮件拆分为单独的消息 ...

📨 电子邮件管理: 轻松回忆电子邮件  /  按主题和其他人阻止诈骗电子邮件  /  删除重复的电子邮件  /  高级搜索  /  合并文件夹 ...

📁 附件专业版批量保存  /  批量分离  /  批量压缩  /  自动保存   /  自动分离  /  自动压缩 ...

🌟 界面魔法: 😊更多又漂亮又酷的表情符号   /  使用选项卡式视图提高 Outlook 工作效率  /  最小化 Outlook 而不是关闭 ...

👍 一键奇迹: 使用传入附件回复全部  /   反网络钓鱼电子邮件  /  🕘显示发件人的时区 ...

👩🏼‍🤝‍👩🏻 通讯录和日历: 从选定的电子邮件中批量添加联系人  /  将联系人组拆分为各个组  /  删除生日提醒 ...

超过 100特点 等待您的探索! 单击此处了解更多。

了解更多       免费下载      购买
 

 

Comments (3)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
MsgBox "Fertig!" & vbCrLf & Zaehler & " Geburtstagseinträge geändert.", vbInformation, "Geburtstage angepasst "

Could you please translate this line for me? TIA
This comment was minimized by the moderator on the site
If possible, could you please give the above directive for auto-count in English??

Danke
This comment was minimized by the moderator on the site
Is there a way to set this up without using the birthday feature of the contact card?

On recurring could you set this up to show the number of years?
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations