自定义MS Project文本样式 [英] Customising MS Project Text Styles

查看:86
本文介绍了自定义MS Project文本样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我试图按资源链接表格中文字的颜色。

I am trying to to link the colour of the text in the table by resource.

我看过一个用背景着色的宏,并尝试根据我的方法调整它,但似乎无法让它正常运行。

I have seen a a macro that colours the background and have tried to adapt this for my means but cannot seem to get it to function properly.

我正在使用5种资源:

关闭,NLT,Imp,PKO,SDTC。

Close, NLT, Imp, PKO, SDTC.

这是我在这里找到的宏:

This is the macro that I found on here:

Sub colormaint()

Outlin eShowAllTask​​s

FilterApply" All Tasks"

SelectAll

Lines = ActiveSelection.Tasks.Count

SelectRow 1

对于Ctr = 2到行 - 1

SelectRow 1,True

如果InStr(ActiveSelection.Tasks(1).ResourceNames," Maint")那么

FontEx CellColor:= pjYellow

Else

FontEx CellColor:= pjWhite

End If

Next Ctr

End Sub

Sub colormaint()
OutlineShowAllTasks
FilterApply "All Tasks"
SelectAll
Lines = ActiveSelection.Tasks.Count
SelectRow 1
For Ctr = 2 To Lines - 1
SelectRow 1, True
If InStr(ActiveSelection.Tasks(1).ResourceNames, "Maint") Then
FontEx CellColor:=pjYellow
Else
FontEx CellColor:=pjWhite
End If
Next Ctr
End Sub

如此有效我需要复制5次。

提前致谢

Gary

推荐答案

嗨Gary,

一种更简单的方法(如果你有大量的资源,可能会更快)就是建立一个包含五个资源名称的过滤器。然后应用过滤器,选择all,并应用格式化。

A simpler way (and possibly faster if you have a large number of resources) is to do it is to build a filter with the five resource names. Then apply the filter, select all, and apply the formatting.

下面我的代码示例应该为您执行此操作 - 只需将要突出显示的资源名称放在顶部的常量中,用逗号分隔(无空格,但过滤器不区分大小写):

My code sample below should do this for you - just put the resource names you want to highlight in the constant at the top, seperated by commas (no spaces, but the filter will be case insensitive):

Sub FormatSelectedResources()

Const ResourceNames = "Close,NLT,Imp,PKO,SDTC"

Dim pj As Project
Dim res As Resource
Dim i As Integer
Dim str_SplitResourceNames() As String

'Split the constant's value using the comma as the delimiter
str_SplitResourceNames = Split(ResourceNames, ",")

'build the filter to identify the resources
Application.ViewApply "Resource Sheet", True
Application.FilterEdit "Highlighted Resources", False, True, True, FieldName:="Name", test:="equals", Value:=str_SplitResourceNames(0), Operation:="or"
For i = 1 To UBound(str_SplitResourceNames())
    Application.FilterEdit "Highlighted Resources", False, NewFieldName:="Name", test:="equals", Value:=str_SplitResourceNames(i), Operation:="or"
Next i

'clear any residual formatting that may be left over
Application.FilterApply "All Resources"
Application.SelectAll
Font32Ex CellColor:=vbWhite

'apply the yellow formatting to the selected resources
Application.FilterApply "Highlighted Resources"
Application.SelectAll
Font32Ex CellColor:=vbYellow

'apply the "All resources" filter
Application.FilterApply "All Resources"
Application.SelectBeginning

End Sub

我希望有所帮助,

Andrew


这篇关于自定义MS Project文本样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆