如何在文档中每个单词的左侧放置一个数字,每个单词都是随机着色的?
我已设法使用以下代码为每个单词编号:
<div>
<tr></tr>
</div>
但是如何将每个数字的颜色更改为随机颜色?
答案 0 :(得分:1)
试试这个
你必须找出随机数字的东西
Option Explicit
Sub IndividualMacros()
Dim i As Long, w As Range
i = 1
Dim aaa As Range
For Each w In ActiveDocument.Words
If w.Text Like "*[A-Z,a-z]*" Then
w.Collapse wdCollapseStart ' move pointer to before word
w.InsertBefore i & " " ' w range contains number and space
' w.select ' you can use this to see the range
w.Font.Color = wdColorBlue ' two ways to color text
w.Font.ColorIndex = 4
i = i + 1
End If
Next
End Sub