Setting Color in VBA

  • Thread starter Wharton Computer Consulting
  • Start date
W

Wharton Computer Consulting

When I set the color for ITEM=pjSummary, I notice that it actually sets the
color for pjMarked. It seems as many of the ITEM constrants are not correct
and setting the wrong "Text Styles". Any ideas.

Below is a snippet of code that only partially works.

TextStylesEx Item:=pjAll, Pattern:=pjSolidFillPattern,
CellColor:=pjColorAutomatic, Color:=pjColorAutomatic
TextStylesEx Item:=pjNoncritical, Pattern:=pjSolidFillPattern,
CellColor:=pjYellow
TextStylesEx Item:=pjCritical, Pattern:=pjSolidFillPattern,
CellColor:=pjRed, Color:=pjYellow
' A = TextStylesEx(pjCritical, , , , , , pjYellow, pjRed, 1)
TextStylesEx Item:=pjMilestone, Pattern:=pjSolidFillPattern,
CellColor:=pjGreen, Color:=pjYellow
TextStylesEx Item:=pjSummary, Pattern:=pjSolidFillPattern,
CellColor:=pjGreen, Color:=pjGreen
' A = TextStylesEx(pjSummary, , , , , , pjYellow, pjGreen, 1)
'
' This sets the Marked Field as Cellcolor blue and
TextStylesEx Item:=pjProjectSummary, Pattern:=pjSolidFillPattern,
CellColor:=pjBlue, Color:=pjYellow

TextStylesEx Item:=pjMarked, Pattern:=pjSolidFillPattern,
CellColor:=pjFuchsia, Color:=pjYellow
TextStylesEx Item:=pjTaskFilterHighlight, Pattern:=pjSolidFillPattern,
CellColor:=pjColorAutomatic
TextStylesEx Item:=pjTaskRowColumnTitles, Pattern:=pjBlue
TextStylesEx Item:=pjGanttMajorTimescale, Pattern:=pjSolidFillPattern,
CellColor:=pjColorAutomatic
TextStylesEx Item:=pjGanttMinorTimescale, Pattern:=pjSolidFillPattern,
CellColor:=pjColorAutomatic
 
R

Rod Gill

Ok, so what version of project, what SP level, which bit of code doesn't
work, what do you expect to have happen and what actually does happen.

What do you have to do to make this work manually (without VBA)? Does that
work for you? (If it can't be done manually it probably can't be done with
VBA.

If you record a macro of you doing what you want manually does the recorded
code work when run?

--

Rod Gill
Microsoft MVP for Project

Author of the only book on Project VBA, see:
http://www.projectvbabook.com




"Wharton Computer Consulting"
When I set the color for ITEM=pjSummary, I notice that it actually sets
the
color for pjMarked. It seems as many of the ITEM constrants are not
correct
and setting the wrong "Text Styles". Any ideas.

Below is a snippet of code that only partially works.

TextStylesEx Item:=pjAll, Pattern:=pjSolidFillPattern,
CellColor:=pjColorAutomatic, Color:=pjColorAutomatic
TextStylesEx Item:=pjNoncritical, Pattern:=pjSolidFillPattern,
CellColor:=pjYellow
TextStylesEx Item:=pjCritical, Pattern:=pjSolidFillPattern,
CellColor:=pjRed, Color:=pjYellow
' A = TextStylesEx(pjCritical, , , , , , pjYellow, pjRed, 1)
TextStylesEx Item:=pjMilestone, Pattern:=pjSolidFillPattern,
CellColor:=pjGreen, Color:=pjYellow
TextStylesEx Item:=pjSummary, Pattern:=pjSolidFillPattern,
CellColor:=pjGreen, Color:=pjGreen
' A = TextStylesEx(pjSummary, , , , , , pjYellow, pjGreen, 1)
'
' This sets the Marked Field as Cellcolor blue and
TextStylesEx Item:=pjProjectSummary, Pattern:=pjSolidFillPattern,
CellColor:=pjBlue, Color:=pjYellow

TextStylesEx Item:=pjMarked, Pattern:=pjSolidFillPattern,
CellColor:=pjFuchsia, Color:=pjYellow
TextStylesEx Item:=pjTaskFilterHighlight, Pattern:=pjSolidFillPattern,
CellColor:=pjColorAutomatic
TextStylesEx Item:=pjTaskRowColumnTitles, Pattern:=pjBlue
TextStylesEx Item:=pjGanttMajorTimescale, Pattern:=pjSolidFillPattern,
CellColor:=pjColorAutomatic
TextStylesEx Item:=pjGanttMinorTimescale, Pattern:=pjSolidFillPattern,
CellColor:=pjColorAutomatic



--
Michael Wharton, MBA, PMP, MCSD, MCSE+I, MCDBA
Wharton Computer Consulting, Inc
"Managing Efficiency thru Technology"


__________ Information from ESET Smart Security, version of virus
signature database 4598 (20091112) __________

The message was checked by ESET Smart Security.

http://www.eset.com

__________ Information from ESET Smart Security, version of virus signature database 4598 (20091112) __________

The message was checked by ESET Smart Security.

http://www.eset.com
 
W

Wharton Computer Consulting

I am running Project Professional 2007 SP2.

I have recorded the macro and see the interger values used for the setting.
I can use the integers, but I wanted to make it more readable by using the
property name.

The only ITEM constant that worked properly was pjCritical.

TextStylesEx Item:=pjCritical,
Pattern:=pjSolidFillPattern,
CellColor:=pjRed, Color:=pjYellow

I was wondering if this is a known bug, or if a reference needed setting or
I was missing something that was obvious.

Thanks
 
J

John

Wharton Computer Consulting
I am running Project Professional 2007 SP2.

I have recorded the macro and see the interger values used for the setting.
I can use the integers, but I wanted to make it more readable by using the
property name.

The only ITEM constant that worked properly was pjCritical.

TextStylesEx Item:=pjCritical,
Pattern:=pjSolidFillPattern,
CellColor:=pjRed, Color:=pjYellow

I was wondering if this is a known bug, or if a reference needed setting or
I was missing something that was obvious.

Thanks

Wharton,
If I may butt in for a moment, a few years back I wrote a macro for a
client that required extensive formatting for various things. I believe
it was under Project 2003. While working on the code I discovered many
of the formatting methods listed in the object browser were flat out
wrong. It sounds like that little issue never got resolved in Project
2007. My solution was to use a trial and error approach with some help
from recorded macros as Rod suggested.

It appears many little VBA aggravations like this never get fixed by the
Project development team. I guess they are considered minor annoyances
and the team has "bigger fish to fry".

John
Project MVP
 
R

Rod Gill

I concur with John. My finding was that some of the pjconstants have the
wrong values. Either use the correct number on its own with a comment to
explain or create your own constants for values used more than once.

--

Rod Gill
Microsoft MVP for Project

Author of the only book on Project VBA, see:
http://www.projectvbabook.com




John said:
Wharton Computer Consulting


Wharton,
If I may butt in for a moment, a few years back I wrote a macro for a
client that required extensive formatting for various things. I believe
it was under Project 2003. While working on the code I discovered many
of the formatting methods listed in the object browser were flat out
wrong. It sounds like that little issue never got resolved in Project
2007. My solution was to use a trial and error approach with some help
from recorded macros as Rod suggested.

It appears many little VBA aggravations like this never get fixed by the
Project development team. I guess they are considered minor annoyances
and the team has "bigger fish to fry".

John
Project MVP

__________ Information from ESET Smart Security, version of virus
signature database 4601 (20091112) __________

The message was checked by ESET Smart Security.

http://www.eset.com

__________ Information from ESET Smart Security, version of virus signature database 4601 (20091112) __________

The message was checked by ESET Smart Security.

http://www.eset.com
 
W

Wharton Computer Consulting

Thanks Rod and Gill,

You guys answer my question. I thought they were wrong too and wanted a
second opinion. So, I think I'll redefine them and drop the code here later.
 
J

John

Wharton Computer Consulting
Thanks Rod and Gill,

You guys answer my question. I thought they were wrong too and wanted a
second opinion. So, I think I'll redefine them and drop the code here later.

Wharton,
Actually it's Rod and John, Gill is Rod's last name. Nonetheless, you're
welcome.

When working with Project VBA sometimes you just gotta fend for yourself.

John
Project MVP
 

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