Script for changing fonts in a Word document

前端 未结 3 1733
粉色の甜心
粉色の甜心 2021-01-24 10:44

I have a Word 2007 file and I want to change all usage of the Courier New font into a Lucida Console font. I need a script that find all words formatted in that font and change

3条回答
  •  野性不改
    2021-01-24 11:35

    This will do it for you:

    Sub ChangeFonts() 
    Dim doc As Document 
    Set doc = ActiveDocument
        For i = 1 To doc.Range.Characters.Count 
            If doc.Range.Characters(i).Font.Name = "Courier New" Then 
                doc.Range.Characters(i).Font.Name = "Lucida Console" 
            End If 
        Next 
    End Sub
    

提交回复
热议问题