View Single Post
 
Old 12-30-2012, 09:33 AM
Jennifer Murphy's Avatar
Jennifer Murphy Jennifer Murphy is offline Windows XP Office 2007
Competent Performer
 
Join Date: Aug 2011
Location: Silicon Valley
Posts: 234
Jennifer Murphy is on a distinguished road
Default

Paul,

Thanks for the suggestion, but I can't get it to work.

Here's my little macro:
Code:
Sub MyRandCharColors()
 
Dim obChar As Range
Dim ilColorNext As Word.WdColorIndex
Dim wdOrange As Long
wdOrange = 41215
Dim vaColors
vaColors = Array(wdBlack, wdRed, wdBlue)
'vaColors = Array(wdBlack, wdOrange)
Dim nsRnd As Single
 
Randomize
For Each obChar In Selection.Characters
  nsRnd = Rnd()
  ilColorNext = vaColors(Int((UBound(vaColors) + 1) * nsRnd))
  obChar.Font.ColorIndex = ilColorNext
Next obChar
 
End Sub
As shown above, it works with the built-in colors. If I remove the comment from the second vaColors statement, it gets Run-time error "5843" indicating that one of the values is out of range.
Reply With Quote