VBA Event in Ms project on completion of task

O

Olivia

There has been need to change the background color of task when someone
enters 100% there in % complete field of MS Project. Is that possible in
VBA??? Bacause i see only taskbefore change event, Not Task after change
event there..
Pls do reply
 
J

John

Olivia said:
There has been need to change the background color of task when someone
enters 100% there in % complete field of MS Project. Is that possible in
VBA??? Bacause i see only taskbefore change event, Not Task after change
event there..
Pls do reply

Olivia,
First of all I assume you are using Project 2007 since that is the first
version that allows background colors for cells. For earlier versions
the best you can do is to change the font characteristics (i.e. color).

Although this potentially could be done with a formula (and a few other
tricks), VBA is probably the better approach. First, go to Format/Text
Styles and select the "items to change" to be the Marked field. Then set
the desired background color. Next, open the VB editor (Tools/Macro/VB
Editor) and select View/Code to open a source code window. Paste the
following code in the window.

Sub chg_backgnd()
Dim t as Task
For Each t In ActiveProject.Tasks
If Not t Is Nothing Then
If t.PercentComplete = 100 Then
t.Marked = True
End If
End If
Next t
End Sub

You will need to run the macro in order to see the changes after
editing. This could be done manually or implemented to run when the
project is closed using the Close Event.

If you want to use this code on multiple files, you should go to the
Organizer and transfer the Module containing this macro code to your
Global file.

Hope this helps.

John
Project MVP
 

Ask a Question

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.

Ask a Question

Top