Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automating Tasks in Sub Project

Status
Not open for further replies.

Palmcrest

Technical User
Jul 10, 2006
66
AU
I was messing around with some code and I can change "Task Bar" formats based on data in "Text1" field.
For example If Text1 = "Area1" then Task Bar will = a nominated colour.
This part is no problem and in a stand alone project it works a treat. BUT
when I run my code in a master project it will not change the task bars in the sub project.
Any thought would be appreciated
I did use SubProject command but I must be missing something.
 
Task bar? Do you mean the Gantt bar for a specific task?

Open the project file that has the code
Open the master project file
Try Tools > Organizer > Modules-tab and copy the appropriate module from the project file that has the code to the master project file.
 
Sorry I did mean Gantt Bar,
I looped through the sub project and got results
when I run the same code in the master I do not get any colour changes of the Gantt bars in the master.

Here is what I have worked with. (text1 contains trigger)
=========================================================
Dim Cnt As Integer

On Error Resume Next
Cnt = 1
Do While Cnt <= ActiveProject.Tasks.Count
Select Case StrConv(Left(ActiveProject.Tasks(Cnt).Text1, 6), vbUpperCase)

Case "AREA 1"
GanttBarFormat TaskID:=Cnt, GanttStyle:=1, StartShape:=0, StartType:=0, StartColor:=0, MiddleShape:=1, MiddlePattern:=1, MiddleColor:=8, EndShape:=0, EndType:=0, EndColor:=0, RightText:="Name"
Case "AREA 2"
GanttBarFormat TaskID:=Cnt, GanttStyle:=1, StartShape:=0, StartType:=0, StartColor:=0, MiddleShape:=1, MiddlePattern:=1, MiddleColor:=2, EndShape:=0, EndType:=0, EndColor:=0, RightText:="Name"
Case "AREA 3"
GanttBarFormat TaskID:=Cnt, GanttStyle:=1, StartShape:=0, StartType:=0, StartColor:=0, MiddleShape:=1, MiddlePattern:=1, MiddleColor:=9, EndShape:=0, EndType:=0, EndColor:=0, RightText:="Name"

Case Else

GanttBarFormat TaskID:=Cnt, GanttStyle:=1, StartShape:=0, StartType:=0, StartColor:=1, MiddleShape:=1, MiddlePattern:=3, MiddleColor:=5, EndShape:=0, EndType:=0, EndColor:=1, LeftText:="Start", RightText:="Name"
End Select

Cnt = Cnt + 1

Loop
=========================================================


This code works in the Sub file Gantt but not in the master Gantt.
I tried changing ActiveProject to Subproject but to no avail.
Your feedback would be appreciated.
 
What happened when you tried:

Open the project file that has the code
Open the master project file
Tools > Organizer > Modules-tab and copy the appropriate module from the project file that has the code to the master project file.

Your code would be better if you used

dim tsk as task
for each tsk in activeproject.tasks
if not tsk is nothing then
select case ...

end select
end if
next


 
PDQBach
I did use the organizer as you suggested but the code only changed GanttBars in the master that were NOT subtasks from subprojects.
When viewing the subproject task GanttBars in the master they did not change.
I will try your additional code and report back.
Thanks

 
Thank you for you advice but this does not seem to work.
I will post up a solution if I can work it out.
The code does work on stand alone projects
It works in the master but will only change Ganttbars that are NOT sub project Gantt Bars.
Using the organiser and adding the recomended code has had nil affect.
Thanks anyway Im sure there is a solution, As they say if you can do it manually you can automate it.
Cheers
 
I guessed (wrongly, it appears) that you were including the sub-project files into the master project. It now seems you were linking to them. In this case, you'll probably have to use Organizer to move the module to each of the sub-projects.

I should have been more specific, too, in my code updates to you since you relied on the counter. Here's one more piece you'll have to change (note: you have severa lines like this so you'll have to make similar changes throughout.)

GanttBarFormat TaskID:=TSK.ID, GanttStyle:=1, StartShape:=0, StartType:=0, StartColor:=0, MiddleShape:=1, MiddlePattern:=1, MiddleColor:=8, EndShape:=0, EndType:=0, EndColor:=0, RightText:="Name"

Sorry if that caused you any grief.
 
I guessed (wrongly, it appears) that you were including the sub-project files into the master project. It now seems you were linking to them. "

No, sorry - It must be frustrating when we are not clear and specific, my apologies.
I have a master project
I have 5 subprojects "inserted" into the master.
The module is in every subproject and in the master project.
The GanttBars in the subs change as required when viewed alone.
When viewed in the Master the GanttBars are default blue and are unaffected by the code.

Observation.
In the master if I have any Tasks that are actually native to the master they WILL respond to the code. However The Tasks in the subprojects when viewed in the master do not respond even though the master native tasks do. Code is present in ALL files.
I also tried
Dim SPrj as Subproject

"for each Tsk in ActiveProject.Subproject"
Im missing something I know, Thanks for having a bash anyways.
Cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top