Microsoft Project 宏中的颜色编码任务

发布于 2024-11-06 01:38:28 字数 375 浏览 12 评论 0原文

这看起来应该是直截了当的,但我看到了一些奇怪的行为。我正在尝试根据标志对我的任务进行颜色编码。它似乎正确地为任务着色,但在处理过程中的某个时刻,着色的初始任务被重置为黑色。它发生的任务似乎也相当不一致。以下是我尝试执行此任务的方式(简化为最简单的形式):

Sub ColorTasks()
    Dim t As Task
    For Each t In ActiveProject.Tasks
        SelectRow t.ID, RowRelative:=False
        Font32Ex Color:=2366701
    Next
End Sub

此代码似乎适用于较小的数据集,但此项目包含大约 2,000 个任务。有什么想法吗?

This seems like it should be straight forward, but I'm seeing some strange behavior. I'm attempting to color code my tasks based on a flag. It appears to be correctly coloring the tasks, but at some point in the processing the initial tasks that were colored are getting reset to black. The task that it happens on seems to be fairly inconsistent too. Here's how I'm trying to perform this task (simplified to it's barest form):

Sub ColorTasks()
    Dim t As Task
    For Each t In ActiveProject.Tasks
        SelectRow t.ID, RowRelative:=False
        Font32Ex Color:=2366701
    Next
End Sub

This code seems to work just fine for smaller data sets, but this project contains around 2,000 tasks. Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

肩上的翅膀 2024-11-13 01:38:28

我知道这是一个老问题,但我希望它对有类似问题的人有用。

错误是你忘记在十六进制数之前添加“H”,所以正确应该是:

Font32Ex CellColor:=&H3A3AD4
etc

I know that this is an old question but I hope it may be useful for someone with similar problem.

The mistake is that you've forgotten to add 'H' before hexadecimal number, so properly there should be:

Font32Ex CellColor:=&H3A3AD4
etc
作业与我同在 2024-11-13 01:38:28

是的,我也遇到了类似的问题::

For Each t In tsks
    Select Case t.Text1
        Case "COMPLETE"
            SelectRow Row:=t.ID, RowRelative:=False
            Font32Ex CellColor:=&659B59
        Case "NOT STARTED"
            SelectRow Row:=t.ID, RowRelative:=False
            Font32Ex CellColor:=&862525
        Case "IN PROGRESS"
            SelectRow Row:=t.ID, RowRelative:=False
            Font32Ex CellColor:=&3A3AD4
    End Select
Next t

根据:http://msdn。 microsoft.com/en-us/library/ff863572.aspx 这应该可以工作,但我每次都会遇到语法错误。我可以让它工作的唯一方法是使用 FontEx 方法,该方法将我限制为只有 16 种颜色......

Yes I too am having a similar problem::

For Each t In tsks
    Select Case t.Text1
        Case "COMPLETE"
            SelectRow Row:=t.ID, RowRelative:=False
            Font32Ex CellColor:=&659B59
        Case "NOT STARTED"
            SelectRow Row:=t.ID, RowRelative:=False
            Font32Ex CellColor:=&862525
        Case "IN PROGRESS"
            SelectRow Row:=t.ID, RowRelative:=False
            Font32Ex CellColor:=&3A3AD4
    End Select
Next t

According to: http://msdn.microsoft.com/en-us/library/ff863572.aspx this should work, yet I get syntax errors every time. Only way I can get this to work is if I use the FontEx method which limits me to only 16 colors....

自我难过 2024-11-13 01:38:28

我发现使用 RGB 值更容易。
Font32Ex CellColor:=RGB(255, 199, 206) '更改填充
Font32Ex Color:=RGB(156, 0, 6) ' 更改字体颜色

使用您的代码,我将整个工作表变成粉红色的红色,350 个任务。我没有办法在 2000 上测试它,尽管不需要做很多额外的工作。

I find it easier to use RGB values.
Font32Ex CellColor:=RGB(255, 199, 206) 'Changes fill
Font32Ex Color:=RGB(156, 0, 6) ' Changes font color

Using your code, I turned my entire sheet to red on pink, 350 tasks. I don't have a means to test it on 2000 though without a lot of extra work.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文