Outlook) (Category.Color 属性

返回或设置一个 OlCategoryColor 常量,该常量指示 Category 对象使用的颜色。 读/写。

语法

表达式颜色

表达 一个代表 Category 对象的变量。

备注

您可以共享相同的颜色为多个类别,通过指定的同一常数,表示对于那些 Category对象 OlCategoryColor枚举中的类别颜色。

示例

下面的 Visual Basic for Applications (VBA) 示例显示一个包含默认 命名空间 的对象具有关联的 类别 集合中包含的每个 类别 对象的颜色分配对话框。

Private Sub ListCategoryColors() 
 Dim objNameSpace As NameSpace 
 Dim objCategory As Category 
 Dim strOutput As String 
 
 ' Obtain a NameSpace object reference. 
 Set objNameSpace = Application.GetNamespace("MAPI") 
 
 ' Check if the Categories collection for the Namespace 
 ' contains one or more Category objects. 
 If objNameSpace.Categories.Count > 0 Then 
 
 ' Enumerate the Categories collection, checking 
 ' the value of the Color property for 
 ' each Category object. 
 For Each objCategory In objNameSpace.Categories 
 
 ' Add the name of the Category object to 
 ' the output string. 
 strOutput = strOutput & objCategory.Name 
 
 ' Add information about the assigned color 
 ' to the output string. 
 Select Case objCategory.Color 
 Case OlCategoryColor.olCategoryColorNone 
 strOutput = strOutput & ": No color" & vbCrLf 
 Case OlCategoryColor.olCategoryColorBlack 
 strOutput = strOutput & ": Black " & vbCrLf 
 Case OlCategoryColor.olCategoryColorBlue 
 strOutput = strOutput & ": Blue" & vbCrLf 
 Case OlCategoryColor.olCategoryColorGray 
 strOutput = strOutput & ": Gray" & vbCrLf 
 Case OlCategoryColor.olCategoryColorGreen 
 strOutput = strOutput & ": Green" & vbCrLf 
 Case OlCategoryColor.olCategoryColorLightBlue 
 strOutput = strOutput & ": Light blue" & vbCrLf 
 Case OlCategoryColor.olCategoryColorLightGray 
 strOutput = strOutput & ": Light gray" & vbCrLf 
 Case OlCategoryColor.olCategoryColorLightGreen 
 strOutput = strOutput & ": Light green" & vbCrLf 
 Case OlCategoryColor.olCategoryColorLightMaroon 
 strOutput = strOutput & ": Light maroon" & vbCrLf 
 Case OlCategoryColor.olCategoryColorLightOlive 
 strOutput = strOutput & ": Light olive" & vbCrLf 
 Case OlCategoryColor.olCategoryColorLightOrange 
 strOutput = strOutput & ": Light orange" & vbCrLf 
 Case OlCategoryColor.olCategoryColorLightPeach 
 strOutput = strOutput & ": Light peach" & vbCrLf 
 Case OlCategoryColor.olCategoryColorLightPurple 
 strOutput = strOutput & ": Light purple" & vbCrLf 
 Case OlCategoryColor.olCategoryColorLightRed 
 strOutput = strOutput & ": Light red" & vbCrLf 
 Case OlCategoryColor.olCategoryColorLightSteel 
 strOutput = strOutput & ": Light steel" & vbCrLf 
 Case OlCategoryColor.olCategoryColorLightTeal 
 strOutput = strOutput & ": Light teal" & vbCrLf 
 Case OlCategoryColor.olCategoryColorLightYellow 
 strOutput = strOutput & ": Light yellow" & vbCrLf 
 Case OlCategoryColor.olCategoryColorMaroon 
 strOutput = strOutput & ": Maroon" & vbCrLf 
 Case OlCategoryColor.olCategoryColorOlive 
 strOutput = strOutput & ": Olive" & vbCrLf 
 Case OlCategoryColor.olCategoryColorOrange 
 strOutput = strOutput & ": Orange" & vbCrLf 
 Case OlCategoryColor.olCategoryColorPeach 
 strOutput = strOutput & ": Peach" & vbCrLf 
 Case OlCategoryColor.olCategoryColorPurple 
 strOutput = strOutput & ": Purple" & vbCrLf 
 Case OlCategoryColor.olCategoryColorRed 
 strOutput = strOutput & ": Red" & vbCrLf 
 Case OlCategoryColor.olCategoryColorSteel 
 strOutput = strOutput & ": Steel" & vbCrLf 
 Case OlCategoryColor.olCategoryColorTeal 
 strOutput = strOutput & ": Teal" & vbCrLf 
 Case OlCategoryColor.olCategoryColorYellow 
 strOutput = strOutput & ": Yellow" & vbCrLf 
 Case Else 
 strOutput = strOutput & ": Unknown" & vbCrLf 
 End Select 
 Next 
 End If 
 
 ' Display the output string. 
 MsgBox strOutput 
 
 ' Clean up. 
 Set objCategory = Nothing 
 Set objNameSpace = Nothing 
 
End Sub

另请参阅

对象类别

支持和反馈

有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。