Macro to Make Task Inactive

H

Hadi

Experts,

I am currently using MS Project 2007. I went to a 2010 conference the other
day and really liked the new task "Inactive" feature. I want to implement
something like it in my Server enviornement to help nvoice users that are not
comfortable with deleting tasks and reconnecting logic. I'm looking to create
a macro that will do the following on any highlighted task or tasks row (not
just the task name cell)

- Fomrat font to sliver, cell background to sliver with parrern 2
- make duration 0, uncheck the "Mark Task as Milestone task"

I recorded a macro and it works if I chose one task, but does not if I have
more than one highlighted. Even, when I use one task it always goes back to
the original task I used to record the macro. here is the macro i recorded

Sub Inactive()
' Macro Inactive
' Macro Recorded Fri 3/12/10 10:04 AM by User.
SelectRow Row:=0
FontEx Italic:=True, Underline:=True, Color:=15, CellColor:=15, Pattern:=2
SelectTaskField Row:=0, Column:="Duration"
SetTaskField Field:="Duration", Value:="0"
SelectTaskField Row:=0, Column:="% Complete"
SelectTaskField Row:=0, Column:="Name"
SetTaskField Field:="Milestone", Value:="No", AllSelectedTasks:=True
End Sub

your help is much appreicated

Hadi
 
J

Jan De Messemaeker

Hi,

How about this:


FontEx Italic:=True, Underline:=True, Color:=15, CellColor:=15, Pattern:=2
for each job in activeselection.tasks
job.duration=0
job.milestone=false
next job

HTH
--
Jan De Messemaeker
Microsoft Project Most Valuable Professional
+32 495 300 620
For availability check:
http://users.online.be/prom-ade/Calendar.pdf
 
J

Jan De Messemaeker

Hi,

The main thing to remember is to avoid working on the selection, use the
task object instead.
Unfortunately this means that the macro generator often generates low
quality code.

--
Jan De Messemaeker
Microsoft Project Most Valuable Professional
+32 495 300 620
For availability check:
http://users.online.be/prom-ade/Calendar.pdf
 
H

Hadi

Jan,

one last thing when i run the macro for sub tasks, the summary task also get
the zero day duration but makes it a milestone. when i run the macro on a
summary i get an error. is it design to only work on childern and parent
tasks?
 
J

Jan De Messemaeker

Hi,

Indeed, you do not have access to the duration of summary tasks- didn't
suppose you were going to select these as well. Here's a more complete code
(you might make things really nasty by also selecting blank lines)
FontEx Italic:=True, Underline:=True, Color:=15, CellColor:=15, Pattern:=2
for each job in activeselection.tasks
if not job is nothing then
if not job.summary then
job.duration=0
job.milestone=false
end if
end if
next job
Greetings,
--
Jan De Messemaeker
Microsoft Project Most Valuable Professional
+32 495 300 620
For availability check:
http://users.online.be/prom-ade/Calendar.pdf
 
H

Hadi

Jan,

This is the code I have now. When I highlight a summary task and its
childer, run the macro below, and then run it, I get an error say the "job"
variable is not defined

Sub TaskInactive()
FontEx Italic:=True, Underline:=True, Color:=15, CellColor:=15, Pattern:=2
For Each job In ActiveSelection.Tasks
If Not job Is Nothing Then
If Not job.Summary Then
job.Duration = 0
job.Milestone = False
End If
End If
Next job
End Sub
 
H

Hadi

Jan,

I'm so sorry to be a pain like this. one more thing. the code works OK. When
I highlight the a Summary task and a sub task, and run the macro. the Summary
task still shows up as Milestone so I want to uncheck the "Milestone" box
off. I tried to add a line of code Job.Summary.Milestone = False below the
Job.Milestone = False, but it's given me a message saying that an Object is
Required

thanks,

Hadi
 
H

Hadi

Jan, I have been trying to fix this issue and I think I got it to work. Can
you or anybody check my code and see if makes sense. thanks again

Sub TaskInactive()
Dim Job As Task
Dim JobS As Task
FontEx Italic:=True, Underline:=True, Color:=15, CellColor:=15, Pattern:=2
For Each Job In ActiveSelection.Tasks
If Not Job Is Nothing Then
If Not Job.Summary Then
Job.Duration = 0
Job.Milestone = False
End If
End If
For Each JobS In ActiveSelection.Tasks
If JobS.Summary Then
JobS.Milestone = False
End If
Next JobS
Next Job
End Sub
 
Joined
Jun 26, 2013
Messages
1
Reaction score
0
Hadi: Thank you for precisely adressing and drafting a functionality which I missed in MSP standard (2013).
Jan De: Thanks for sharing Your excellent skills and creating a solution!

In other Words: Thanks for making my job easier :)
 

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