Indenting tasks based on their wbs number.

M

Micky Singh

I want to automatically indent tasks (creating subtasks) via a macro or
VBA code based on the task’s WBS number

For example

WBS no. Task name

Project Task 0
1 Task 1
1.1 Task 2
1.1.1 Task 3
1.1.2 Task 4
1.2 Task 5
1.2.1 Task 6
2 Task 7
2.1 Task 8
2.1.1 Task 9
3 Task 10

1, 2 and 3 are all subtasks of project.
1.1 and 1.2 are subtasks of 1
1.1.1 and 1.1.2 are subtasks of 1.1


Thanks


Mike
 
J

Jan De Messemaeker

Hi,

I suppose you enter the WBS number manually

The VBA snippet goes like this:

Old_Lvl=1
For each tsk in activeproject.tasks
if not tsk is nothing then
wbsno=tsk.text1
'I suppose the wbs numbe ris in the text1 field

Number_of_dots=len(WBSNo)-len(replace(WBSNo,".","")
Lvl=number_of_dots+1
if lvl>Old_Lvl then
Tsk.indent
end if
if lvl<Old_Lvl then
tsk.outdent
end if
old_lvl=lvl
end if
next tsk

Hope this helps
 
J

Jim Aksel

The best way to do it is with the indent key. Programatically:
Assuming you have the tasks listed in correct WBS order, I would count the
number of decimal places in the WBS after reading it into a string. Let's
call it count.
So, the Outline level would be count+1.
Loop through each task in the project and assign tsk.OutLineLevel=count+1
--
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
 

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