View Single Post
 
Old 06-04-2020, 03:38 AM
lizat lizat is offline Windows 7 64bit Office 2010 64bit
Novice
 
Join Date: Nov 2012
Posts: 4
lizat is on a distinguished road
Default Setting conditional fromat using VBA

I want to 'grey' my tasks that are complete. I created some code which set the colours wrongly (black and yellow). so i decided to reset all to neutral and then apply my colours but it doesn't quite work. i have played with colours to try and understand what is being set but have got very confused. I have checked Text styles in case that was causing any problems but nothing obvious. The problems:https://www.screencast.com/t/whiJYzD3
  • I thought I'd set the text temporarily to red (&HFF0000) but it comes out blue, have I misunderstood something basic?
  • I can't get rid of the black and yellow, why doesn't the Case 0 - 100 catch this?
  • I there may be a way of applying default style - what is it?
  • I want to confirm I am using the correct attribute (percentComplete) but can't find a reference for this
  • i think text styles are applied before the vb is executed so can be overwritten, is that correct?
  • when I enter a six character hex code sometimes the editor creates a 'short version. e.g. &H000000 results in &H0, but this means that &H00FF00 (green) becomes &HFF00 which results in black or dark grey. How does this work?

there may be a better way to do this but here is the code:
Quote:
Sub FormatCompletedTasks()

For Each tskT In ActiveProject.Tasks

Select Case tskT.PercentComplete
Case 0 - 100 'reset all to default'
SelectRow Row:=tskT.ID, RowRelative:=False
Font32Ex Color:=&H0, CellColor:=&HFFFFFF
End Select

Select Case tskT.PercentComplete
Case 100 'set 100% complete to grey
SelectRow Row:=tskT.ID, RowRelative:=False
Font32Ex Color:=&HFF0000, CellColor:=&HDDDDDD 'temp set text to red
End Select
Next tskT

End Sub
Any suggestions? Thank you
Reply With Quote