VBA Coding for making the font bolded

I

iftamrak

I created an extract from excel in MSP2007, Professional. There are three
columns in the plan. The taskname, the baseline finish and flag2. The last
column has a Yes or No value.

I would like to have the fonts in the Task Name column bolded, when the
value of Flag2 is a Yes.

** I have already tried using the Format, Text Styles, and Item to Change.
There is no value that I can check in Flag2 here.

We wrote a VBA and we still could not get this to work. The codes are the
following:


Public Sub BoldFont()

Dim tsk As Task
For Each tsk In ActiveProject.Tasks
If Not tsk Is Nothing Then
SelectRow tsk.UniqueID, RowRelative:=False
SelectTaskField Row:=tsk.UniqueID, _
RowRelative:=False, Column:="Name"
Font Bold:=True
End If
Next
End Sub


Can anyone assist how can I make adjustments to the code? Thank you.
 
J

JulieS

Hello iftamrak,

A couple of options:

If you are importing data from excel, consider importing the "Yes" or
"No" into the Marked field instead of Flag2. You can then use Text
Styles to set the format of Marked tasks to bold.

If you've already entered the data in Flag2, then you can run the code
below to set the Marked field to "yes" if Flag2 is "yes". By using
the Marked field the advantage is all you need to do is run the code
once to set Marked to the correct value and then if you change Marked
again, the font will automatically change.

Sub MarkFlag2()
Dim tsk As Task
For Each tsk In ActiveProject.Tasks
If Not tsk Is Nothing Then
If tsk.Flag2 = True Then
tsk.Marked = True
End If
End If
Next tsk
End Sub

I hope this helps. Let us know how you get along.

Julie
Project MVP

Visit http://project.mvps.org/ for the FAQs and additional information
about Microsoft Project
 
I

iftamrak

Thank you so much. Everything is working great and your suggestions are very
helpful.
 

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