C
ChuckB
Would like to highlight every other row in a project plan; is VBA code the
ansher
and, if so, can I see an example.
Thanks,
Chuck
ansher
and, if so, can I see an example.
Thanks,
Chuck
ChuckB said:Would like to highlight every other row in a project plan; is VBA code the
ansher
and, if so, can I see an example.
Thanks,
Chuck
"can't find project or library" when I ran the macro.John said:Chuck,
Be advised that Project is not like Excel. The field cell background
cannot be colored. You can however "highlight" field cells, row data or
column data by changing the font characteristics. And yes, that can be
done easily with VBA. The following code will change the text of all
even ID tasks to blue.
Sub Even_row_highlight()
i = 1
For Each t In ActiveProject.Tasks
If Not t Is Nothing Then
If t.ID = 2 * i Then
SelectRow Row:=t.ID, rowrelative:=False
Font Color:=pjBlue
i = i + 1
End If
End If
Next t
Hope this helps.
John
Project MVP
I copied the code into my project and got an error messagte
ChuckB said:"can't find project or library" when I ran the macro.
Thanks,
Chuck
John said:Chuck,
Well at least you found the right post - that's part "A".
I will assume you know how to set up and run a macro. If not, I'll
provide instructions.
The error message you get sounds like a reference needs to be set for
the object library. From the VB Editor go to Tools/References. As a
minimum, the following references should be checked:
1. Visual Basic for Applications
2. Microsoft Project xx.x Object Library (xx.x is the version of Project
you have installed - 11.0 is for Project 2003)
3. If those aren't checked, find them and check them
4. If it still gives the error, then also add the following references:
a. OLE Automation
b. Microsoft Office xx.x Object Library
5. When all object references are checked, hit "ok"
If the code still fails to execute, tell me exactly how you copied the
code and how you are attempting to run it. It would also be helpful to
know which version of Project you are using although for this simple
macro, it shouldn't matter.
John
Project MVP
John:
Thanks for all the help and patience; I followed your suggestions and it
worked perfectly; is it possible to substitute other font changes for the
color that is currently
in the code--e.g., Font bold ??
Once again, thanks.
Chuck
John said:Chuck,
You're welcome.
To see all the options for the Font Method, open the VB Editor and hit
the "Object Browser"icon or select it from the View menu. When the
object browser appars, in the upper selection box on the far upper left,
select "MSProject". In the selection box immediately below it, type in
"font". Then hit the binocular icon. The Search Results will list
several "finds" with the first one already selected. Hit the question
mark (Help) icon. The complete VB syntax for the Font Method will appear.
Hope this helps.
John
Project MVP
Thanks for all the help; I learned quite a bit about VB from this exercise.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.