Save Baseline for SubProjects from MasterProject

J

Jim Aksel

I am attempting to save a baseline (could be baseline1, baseline2, etc.) from
a master project down into the subordinate projects. That is, if I decide to
set a baseline for a master projectd, I want to also save the same baseline
number for all the inserted subprojects.

The code below appears to work only on the tasks in the master project and
does not propagate into the other files. Any ideas would be helpful. Our
alternative is to do it manually in each file.

Note this code works fine for setting status dates in each file (need to
change only one line of code)

Public Sub DriveDownBaseline5()
Call DrillBaseline5(Application.ActiveProject)
End Sub

Private Sub DrillBaseline5(ByRef mProject As Project)

Dim bProject As Project
Dim sProject As Subproject

'This overwrites entire Baseline5 for entire mProject
'However it only appears to work for the active project
BaselineSave All:=True, Copy:=pjCopyCurrent, Into:=pjIntoBaseline5

If mProject.Subprojects.Count = 0 Then
'base case do nothing, baseline already saved
Exit Sub
Else
For Each sProject In mProject.Subprojects
Set bProject = sProject.SourceProject
Call DrillBaseline5(bProject)
Next sProject
End If
End Sub
 
J

Jan De Messemaeker

Hi,

It's in your logic I'm afraid
You Call DrillBaseline5(bProject)
bProject being a simple project it falls into this trap:
If mProject.Subprojects.Count = 0 Then
'base case do nothing, baseline already saved
Exit Sub
because the value of mproject now is bproject wich does not have any subs.
Hope this helps,
 
J

Jim Aksel

You are awake late, I was expecting Rod to chime in since he's just waking up.
Anyway, I tried commenting out the test and that does not correct the problem.

Actually, the logic seems sound as well. The first thing the subroutine does
is save the baseline for mProject.... then calls recursively if there are
subprojects. Some of our projects are master projects inside of other
master projects so I have to check for that condition.

I have a series of 6 very small project files demonstrating this. I'd be
happy to send them if you want to play.

Jim
--
If this post was helpful, please consider rating it.

Jim
It''s software; it''s not allowed to win.

Visit http://project.mvps.org/ for FAQs and more information
about Microsoft Project
 
J

Jan De Messemaeker

You can send them but I stick to my remark. When you call the drill with
bproject as an argument nothing will happen.

jandemesATprom-ade DOT be
 
J

Jim Aksel

Please check you e-mail, I sent you some debug.print statements, my code and
some sample files.

I believe the problem is the

BaselineSave line is working only on ActiveProject.BaselineSave

I want it to work like this:
mProject.BaselineSave

but that is not valid code because mProject is a Project Object and
<expression>.BaselinesSave wants <expression> to be an application object.
 
J

Jan De Messemaeker

Hi,

The solution is to open the subproject (using Fileopen) before applying the
baselinesave.
HTH
 

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