我想计算包含三个不同颜色项目符号的文本中的所有项目符号项目,该项目不是索引颜色,而是服装RGB(,例如 51,204,204 )。然后要显示每种颜色的数量(,例如 42蓝色) 所以想出了这个,但不编译和说“无效限定符”指向“.Font”,我在代码中突出显示:VBA(MSWord):无法找到具有特定rgb颜色的项目符号点
Sub GetNumberOfBullets()
Dim objRange As Range
Dim objParagraph As Paragraph
Dim nNumber As Integer
' Initialization
Set objRange = Selection.Range
nNumber = 0
cyannum = 0
purplenum = 0
greennum = 0
For Each objParagraph In objRange.Paragraphs
If objParagraph.Range.ListFormat.ListType = WdListType.wdListBullet Then
nNumber = nNumber + 1
If objParagraph.Range`.Font`.Color.RGB = RGB(51, 204, 204) Then
cyannum = cyannum + 1
End If
If objParagraph.Range`.Font`.Color.RGB = RGB(204, 153, 255) Then
purplenum = purplenum + 1
End If
If objParagraph.Range`.Font`.Color.RGB = RGB(0, 176, 80) Then
greennum = greennum + 1
End If
End If
Next objParagraph
' Pop up a message box to show the total number of bullets.
MsgBox ("Bullet number:" & nNumber & "Cyan number:" & cyannum & "Purple number:" & purplenum & "Green number:" & greennum)
End Sub
这是一个迷宫!我的建议是不去那里。基本上,项目符号的字体与文本的字体不同地指定。有无数的物体,其中有些物体不能按照您所期望的方式存取,没有一个物体有良好的文件记录,也没有关于它们如何一起工作的文件。如果你坚持,我发现的最好的帮助可以在http://www.shaunakelly.com/word/bullets/controlbullets20072010.html – Variatus