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

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我知道这是一个老问题,但我希望它对有类似问题的人有用。
错误是你忘记在十六进制数之前添加“H”,所以正确应该是:
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:
是的,我也遇到了类似的问题::
根据:http://msdn。 microsoft.com/en-us/library/ff863572.aspx 这应该可以工作,但我每次都会遇到语法错误。我可以让它工作的唯一方法是使用 FontEx 方法,该方法将我限制为只有 16 种颜色......
Yes I too am having a similar problem::
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....
我发现使用 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.