首页 > 解决方案 > 获取当前选择的 Outlook 约会

问题描述

我想在 Outlook 中有一个按钮,将所选 Outlook 约会的类别(在日历窗口中)更改为“绿色类别”。

Sub set_to_solved()
    Dim objApp As Outlook.Application
    
    Dim citem As Outlook.AppointmentItem
    
    citem.Categories = "Green Category"
    
End Sub

我在想我没有引用所选项目。

标签: vbaoutlook

解决方案


首先,您永远不会初始化citem有价值的东西,其次,您永远不会在设置Categories属性后保存约会。

dim citem As object
for each citem in Application.ActiveExplorer.Selection
  if citem.Class = 26 Then 'olAppointment 
    citem.Categories = "Green Category"
    citem.Save
  End If
next

推荐阅读