Word batch modify cross-reference color

In order to increase the readability of academic papers, the fonts of literature citations and chart cross-references in papers are often set to special colors. It is quite cumbersome to manually set one by one. We can use Word's macro to modify the cross-reference font color in batches.

1. Click "View→Macro→View Macro→Create"

insert image description here

2. Click "Create" in the pop-up dialog box

insert image description here

3. Clear the code area

insert image description here

4. Enter the following code

Sub CitingColor()
    For i = 1 To ActiveDocument.Fields.Count '遍历文档所有域
        If Left(ActiveDocument.Fields(i).Code, 4) = " REF" Then 'Word自带的交叉引用的域代码起始4位是" REF"(注意空格
        ActiveDocument.Fields(i).Select '选中上述几类域
        Selection.Font.Color = wdColorBlue '设置字体颜色为蓝色,也可以使用以下代码设置为任意颜色Selection.Font.Color = 12673797
        End If
    Next
End Sub

insert image description here

5. Save and close the step 4 interface, click the run in the step 2 picture

Guess you like

Origin blog.csdn.net/weixin_40575956/article/details/127960138