本文介绍了VBA字。超链接的HighlightColorIndex返回9999999的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Word中编写一个宏来删除用 wdGray25 突出显示的所有超链接中的突出显示。搜索所有超链接是通过

I'm writing a macro in Word to remove the highlighting from all hyperlinks highlighted with wdGray25. The search for all hyperlinks is done by

For Each oLink In ActiveDocument.Hyperlinks
    If oLink.Range.HighlightColorIndex = wdGray25 Then
    oLink.Range.HighlightColorIndex = wdNoHighlight
    End If
Next oLink

问题是不会删除用 wdGray25 突出显示的某些超链接突出显示。通过检查Alt + f9的超链接,似乎 wdGray25 突出显示不会从那些超链接/字段(仅由Alt + f9显示)未突出显示的超链接中删除。当隐藏超链接/字段时,这些超链接通常会突出显示。对于这些超链接 Range.HighlightColorIndex 返回9999999.

The problem is that highlighting from some hyperlinks highlighted with wdGray25 is not removed. By examining hyperlinks with Alt+f9 it appears that wdGray25 highlighting isn't removed from those hyperlinks whose hyperlink/field (revealed only by Alt+f9) isn't highlighted. These hyperlinks seem normally highlighted when hyperlink/field is hidden. For these hyperlinks Range.HighlightColorIndex returns 9999999.

如何重写代码以便 wdGray25 即使未突出显示超链接/字段,也会找到超链接?

How can I rewrite the code so that wdGray25 hyperlinks are found even though hyperlink/field isn't highlighted?

推荐答案

您可以利用这些隐藏超链接具有9999999作为 HighlightColorIndex property

you could exploit the knowledge that those "hidden" hyperlinks have 9999999 as HighlightColorIndex property

For Each oLink In ActiveDocument.Hyperlinks
    Select Case oLink.Range.HighlightColorIndex
        Case 9999999, wdGray25
            oLink.Range.HighlightColorIndex = wdNoHighlight
    End Select
Next oLink

这篇关于VBA字。超链接的HighlightColorIndex返回9999999的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 22:01