如何计算Outlook中约会或会议上花费的小时/天/周?
假设Outlook中的日历中有很多约会和会议。 现在您要计算在这些约会和会议上花费的小时/天/周,您知道吗? 本文将介绍一个VBA来帮助您。
计算与VBA约会或开会所花费的小时/天/周
此方法将引入VBA,以计算在Outlook中指定约会或会议上花费的小时或分钟。 请执行以下操作:
1.移至“日历”文件夹,然后单击以选择要计算花费的时间的约会或会议。
2。 按 其他 + F11 同时按下两个键可以打开“ Microsoft Visual Basic for Applications”窗口。
3。 点击 插页 > 模块,然后将以下VBA代码粘贴到打开的“模块”窗口中。
VBA:计算在Outlook中的约会或会议上花费的小时/分钟
Sub CountTimeSpent()
Dim oOLApp As Outlook.Application
Dim oSelection As Outlook.Selection
Dim oItem As Object
Dim iDuration As Long
Dim iTotalWork As Long
Dim iMileage As Long
Dim iResult As Integer
Dim bShowiMileage As Boolean
bShowiMileage = False
iDuration = 0
iTotalWork = 0
iMileage = 0
On Error Resume Next
Set oOLApp = CreateObject("Outlook.Application")
Set oSelection = oOLApp.ActiveExplorer.Selection
For Each oItem In oSelection
If oItem.Class = olAppointment Then
iDuration = iDuration + oItem.Duration
iMileage = iMileage + oItem.Mileage
ElseIf oItem.Class = olTask Then
iDuration = iDuration + oItem.ActualWork
iTotalWork = iTotalWork + oItem.TotalWork
iMileage = iMileage + oItem.Mileage
ElseIf oItem.Class = Outlook.olJournal Then
iDuration = iDuration + oItem.Duration
iMileage = iMileage + oItem.Mileage
Else
iResult = MsgBox("Please select some Calendar, Task or Journal items at first!", vbCritical, "Items Time Spent")
Exit Sub
End If
Next
Dim MsgBoxText As String
MsgBoxText = "Total time spent: " & vbNewLine & iDuration & " minutes"
If iDuration > 60 Then
MsgBoxText = MsgBoxText & HoursMsg(iDuration)
End If
If iTotalWork > 0 Then
MsgBoxText = MsgBoxText & vbNewLine & vbNewLine & "Total work recorded; " & vbNewLine & iTotalWork & " minutes"
If iTotalWork > 60 Then
MsgBoxText = MsgBoxText & HoursMsg(iTotalWork)
End If
End If
If bShowiMileage = True Then
MsgBoxText = MsgBoxText & vbNewLine & vbNewLine & "Total iMileage; " & iMileage
End If
iResult = MsgBox(MsgBoxText, vbInformation, "Items Time spent")
ExitSub:
Set oItem = Nothing
Set oSelection = Nothing
Set oOLApp = Nothing
End Sub
Function HoursMsg(TotalMinutes As Long) As String
Dim iHours As Long
Dim iMinutes As Long
iHours = TotalMinutes \ 60
iMinutes = TotalMinutes Mod 60
HoursMsg = " (" & iHours & " Hours and " & iMinutes & " Minutes)"
End Function
4。 按 F5 键或单击 运行 按钮以运行此VBA。
现在会弹出一个对话框,显示所选约会/会议花费了多少小时/分钟。 看截图:
备注:您可以同时选择多个约会或会议,以使用此VBA代码计算在这些约会或会议上花费的总时/分。
相关文章
最佳办公生产力工具
Kutools for Outlook - 超过 100 种强大功能可增强您的 Outlook
🤖 人工智能邮件助手: 具有人工智能魔力的即时专业电子邮件——一键天才回复、完美语气、多语言掌握。轻松改变电子邮件! ...
📧 电子邮件自动化: 外出(适用于 POP 和 IMAP) / 安排发送电子邮件 / 发送电子邮件时按规则自动抄送/密件抄送 / 自动转发(高级规则) / 自动添加问候语 / 自动将多收件人电子邮件拆分为单独的消息 ...
📨 电子邮件管理: 轻松回忆电子邮件 / 按主题和其他人阻止诈骗电子邮件 / 删除重复的电子邮件 / 高级搜索 / 合并文件夹 ...
📁 附件专业版: 批量保存 / 批量分离 / 批量压缩 / 自动保存 / 自动分离 / 自动压缩 ...
🌟 界面魔法: 😊更多又漂亮又酷的表情符号 / 使用选项卡式视图提高 Outlook 工作效率 / 最小化 Outlook 而不是关闭 ...
👍 一键奇迹: 使用传入附件回复全部 / 反网络钓鱼电子邮件 / 🕘显示发件人的时区 ...
👩🏼🤝👩🏻 通讯录和日历: 从选定的电子邮件中批量添加联系人 / 将联系人组拆分为各个组 / 删除生日提醒 ...
超过 100特点 等待您的探索! 单击此处了解更多。