简体   繁体   English

我可以在 MS Project 中使用条件格式来根据任务名称文本更改文本颜色吗?

[英]Can I use Conditional Formatting in MS Project to change text color based on Task Name Text?

In MS Projects, I need to utilize VBA to conditionally format all rows with "payment" somewhere in the Task Name to have bold, red text.在 MS Projects 中,我需要利用 VBA 有条件地将任务名称中某处带有“付款”的所有行格式化为粗体红色文本。

This code should do what you want.这段代码应该做你想做的。

Option Compare Text
Sub BoldRed()
OutlineShowAllTasks
FilterEdit Name:="temp", taskfilter:=True, create:=True, overwriteexisting:=True, FieldName:="Name", test:="contains", _
    Value:="payment", ShowInMenu:=False, showsummarytasks:=True
FilterApply Name:="Temp"
SelectTaskColumn Column:="name"
Font32Ex Bold:=True
Font32Ex Color:=255
FilterApply Name:="all tasks"
OrganizerDeleteItem Type:=pjFilters, FileName:=ActiveProject.Name, Name:="temp"
            
End Sub

Based on extended comments on prior answer, here is another version of a macro to format the entire row of tasks that contain 'payment' or 'go-live' in the task name.基于对先前答案的扩展评论,这里是另一个版本的宏,用于格式化任务名称中包含“付款”或“上线”的整行任务。

Sub FormatSpecificTasks()

    OutlineShowAllTasks
    FilterEdit Name:="temp", TaskFilter:=True, Create:=True _
        , OverwriteExisting:=True, FieldName:="Name", Test:="contains" _
        , Value:="payment", ShowInMenu:=False, ShowSummaryTasks:=False
    FilterEdit Name:="temp", TaskFilter:=True, FieldName:="" _
        , NewFieldName:="Name", Test:="contains", Value:="go-live" _
        , Operation:="Or", ShowSummaryTasks:=False
    FilterApply Name:="temp"
    SelectAll
    Font32Ex Bold:=True, Color:=255, CellColor:=RGB(255, 229, 99) 
    FilterApply Name:="all tasks"
    OrganizerDeleteItem Type:=pjFilters, FileName:=ActiveProject.Name, Name:="temp"
            
End Sub

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM