This code is to teach / illuminate, and is not anted up as a solution to your challenge. However, I do hope it will be a stepping stone to your solution ...
Option Explicit
Function [color=red]IsLike[/color](text As String, pattern As String) As Boolean
[color=green]'' quick and dirty but should work[/color]
If InStr(pattern, ",") > 0 Then
Dim patterns() As String, _
i As Integer
patterns = Split(pattern, ",")
For i = 0 To UBound(patterns)
If text Like patterns(i) Then
IsLike = True
Exit Function
End If
Next i
IsLike = False
Else
IsLike = text Like pattern
End If
End Function
Sub [color=red]ColorByOveride[/color]()
Dim block As AcadBlock, _
ent As AcadEntity, _
diment As AcadDimension, _
override As String
For Each block In ThisDrawing.Blocks
If block.IsLayout Then
For Each ent In block
If ent.ObjectName Like "AcDb*Dimension" Then
Set diment = ent
override = UCase$(diment.TextOverride)
If override = "" Then
'[color=green]' Not overridden, so normal dimstyle colour should
'' be "ByLayer" (acByLayer), not neccesarilly white.
'' However, for this exervise I will force white so
'' you can definitively see what dims met this test.[/color]
diment.TextColor = acWhite
ElseIf override Like "<> ?*" Then
[color=green]'' You wanted white, but for the sake of differ-
'' entiating the results I chose yellow.[/color]
diment.TextColor = acYellow
ElseIf IsNumeric(override) Then
[color=green]'' Should be self explanatory.[/color]
diment.TextColor = acGreen
ElseIf [color=red]IsLike[/color](override, "# [A-Z]*,## [A-Z]*,### [A-Z]*,#### [A-Z]*") Then
[color=green]'' You wanted white + green. I don't think you can
'' specify different colors for each "word" in the
'' override text. Your challenge as budding programmer
'' is to prove me wrong.[/color]
[color=green]'' Anyway, to differentiate your test results I chose
'' to make dims that met this condition magenta.[/color]
diment.TextColor = acMagenta
Else
[color=green]'' We failed to trap the override's characteristics
'' so this is our default, color it red so you can
'' differentiate.[/color]
diment.TextColor = acRed
End If
End If
Next ent
End If
Next block
End Sub
Cheers.