Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
other
informationbridge
office.intranets
office.misc
office.setup
office.xml
officeupdate
onenote
photodraw.discussion
powerpoint
producer
proj.standard&server
project
project.developer
project.pro_and_serve
project.server
project.vba
project2000
publisher
publisher.prepress
publisher.programming
publisher.webdesign
visio
visio.createshapes
visio.database.modeling
visio.dev.diagrams
visio.dev.shapesheet
visio.dev.vba
visio.dev.vc
visio.developer
visio.general
visio.installation
visio.printing
visio.software.modeling
visio.troubleshoot
  
 
date: Fri, 15 Aug 2008 05:35:35 -0700 (PDT),    group: microsoft.public.project.developer        back       


Applying a macro to linked projects   
I have the following peice of code that changes text color based on
the task status (thanks Jan).  The code works fine except when I
expand a linked project.  The tasks in the linked project do not
appear in the correct colors.  Is there a way to remedy that?  The
code runs when the project is opened.

Private Sub Project_Open(ByVal pj As Project)
ViewApply "Gantt Chart"

FilterApply "All Tasks"

OutlineShowAllTasks


For Each Tsk In ActiveProject.Tasks
If Not Tsk Is Nothing Then

Select Case Tsk.Status
   Case pjLate

 SelectRow Row:=Tsk.ID, RowRelative:=False
 Font Color:=pjRed

Case pjComplete
SelectRow Row:=Tsk.ID, RowRelative:=False
Font Color:=pjGreen

Case pjOnSchedule
SelectRow Row:=Tsk.ID, RowRelative:=False
Font Color:=pjBlue

Case Else
SelectRow Row:=Tsk.ID, RowRelative:=False

 Font Color:=pjBlack
End Select
End If 'Nothing
Next Tsk
SendKeys ("^{HOME},^s")
End Sub
date: Fri, 15 Aug 2008 05:35:35 -0700 (PDT)   author:   unknown

Re: Applying a macro to linked projects   
In article 
,
 ggarmon@crh.org wrote:

> I have the following peice of code that changes text color based on
> the task status (thanks Jan).  The code works fine except when I
> expand a linked project.  The tasks in the linked project do not
> appear in the correct colors.  Is there a way to remedy that?  The
> code runs when the project is opened.
> 
> Private Sub Project_Open(ByVal pj As Project)
> ViewApply "Gantt Chart"
> 
> FilterApply "All Tasks"
> 
> OutlineShowAllTasks
> 
> 
> For Each Tsk In ActiveProject.Tasks
> If Not Tsk Is Nothing Then
> 
> Select Case Tsk.Status
>    Case pjLate
> 
>  SelectRow Row:=Tsk.ID, RowRelative:=False
>  Font Color:=pjRed
> 
> Case pjComplete
> SelectRow Row:=Tsk.ID, RowRelative:=False
> Font Color:=pjGreen
> 
> Case pjOnSchedule
> SelectRow Row:=Tsk.ID, RowRelative:=False
> Font Color:=pjBlue
> 
> Case Else
> SelectRow Row:=Tsk.ID, RowRelative:=False
> 
>  Font Color:=pjBlack
> End Select
> End If 'Nothing
> Next Tsk
> SendKeys ("^{HOME},^s")
> End Sub

ggarmon,
Well, yes there is a way to do it but remember that inserted projects 
are not actually part of the master. If you change font color of 
subproject task data at the master level it will NOT change that color 
in the actual subproject, the color change will only show at the master 
level. There is a way to change the color of the actual subproject task 
data but the code would have to open and select the subproject task 
itself.

That said, to change the color at the master level, expand the 
subproject (OutlineShowTasks expandinsertedprojects:=True), and then set 
up an object of all tasks in the current view and loop on those. For 
example,
SelectTaskColumn
Set area = ActiveSelection.Tasks

Hope this helps.
John
Project MVP
date: Fri, 15 Aug 2008 07:09:09 -0700   author:   John

Re: Applying a macro to linked projects   
Hi,

You should have said that from the start: the tasks in the view do not 
belong to the master project so you do not access them. Instead, use this 
method to go to the tasks:

Selectall
Tall=activeselection.tasks.count
for counter=1 to tall
selectrow row:=counter, rowrelative:=false
set tsk=activeselection.tasks(1)
if not tsk is nothing then
....

end if 'nothing
next counter

HTH


-- 
Jan De Messemaeker
Microsoft Project Most Valuable Professional
+32 495 300 620
For availability check:
http://users.online.be/prom-ade/Calendar.pdf
 wrote in message 
news:2f23c17e-14f0-4084-a814-e51853289dde@34g2000hsh.googlegroups.com...
>I have the following peice of code that changes text color based on
> the task status (thanks Jan).  The code works fine except when I
> expand a linked project.  The tasks in the linked project do not
> appear in the correct colors.  Is there a way to remedy that?  The
> code runs when the project is opened.
>
> Private Sub Project_Open(ByVal pj As Project)
> ViewApply "Gantt Chart"
>
> FilterApply "All Tasks"
>
> OutlineShowAllTasks
>
>
> For Each Tsk In ActiveProject.Tasks
> If Not Tsk Is Nothing Then
>
> Select Case Tsk.Status
>   Case pjLate
>
> SelectRow Row:=Tsk.ID, RowRelative:=False
> Font Color:=pjRed
>
> Case pjComplete
> SelectRow Row:=Tsk.ID, RowRelative:=False
> Font Color:=pjGreen
>
> Case pjOnSchedule
> SelectRow Row:=Tsk.ID, RowRelative:=False
> Font Color:=pjBlue
>
> Case Else
> SelectRow Row:=Tsk.ID, RowRelative:=False
>
> Font Color:=pjBlack
> End Select
> End If 'Nothing
> Next Tsk
> SendKeys ("^{HOME},^s")
> End Sub
date: Fri, 15 Aug 2008 16:22:25 +0200   author:   Jan De Messemaeker

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us