Here's some things to consider... The WBS in project is of the form
a.b.c.d.e.f etc.
Unfortunately, the width (number of characters) in this is actually
unkown... could be 1.2.3. or 314.5.888.12 for a WBS right? Actually, you
can use a WBS mask to force it to fixed widths, but let's get more "sporting"
than that....
This is going to take some VBA type programming... and should be posted to
the developer group. However, since we are here, I will offer you some
solutions.
What you care about is "level2". That is you want to remove the .b.
a.b.c.d.e becomes a.c.d.e
You need a formula that strips out the first bit of the WBS (stops at the
first period) and then "remembers" that. You then need to fast forward in
the string to the second period (whose position is technically unkown). From
there, you take the "rest of the WBS" and concatonate on to what you
"remembered" so, here's a go at it...
Dim tsk as Task
dim strLeader as string
dim myWBS as string
dim intPosition as integer
dim strRemainder as string
for each tsk in ActiveProject.Tasks
myWBS=str(tsk.WBS) 'writes the WBS to a string
intPosition=instr(myWBS,".") 'Finds location of the first period in myWBS,
an integer
strLeader=Left(myWBS,intPosition-1) 'play with it - you may not need the
minus 1
strRemainder=mid(myWBS,intPosition+1) 'start just after first . and take
the rest
'Now we find the second period the same way by coaxing the remainder
intPosition=instr(strRemainder,".") 'second period is the first one in the
remainder
'overwrite the remainder with just the stuff to the right of the "second"
period.
strRemainder=mid(strRemainder,intPosition+1)
'Write the new WBS out to Text1 on the view
tsk.Text1=strLeader & "." & strRemainder
Next tsk
Well, that is probably not the whole thing, and I have not checked it. But
it's a good start for a Friday afternoon after a nice afternoon cold one.
I'm sure if I put some more thought in on it, I could knock off a lot of the
code...but this is pretty straight forward.
HTH
-
If this post was helpful, please consider rating it.
Jim Aksel, MVP
Check out my blog for more information:
http://www.msprojectblog.com