View Single Post
 
Old 06-07-2022, 01:28 AM
w64bit w64bit is offline Windows 8 Office 2013
Novice
 
Join Date: Jan 2015
Posts: 19
w64bit is on a distinguished road
Default Replace font (multiple files)

I am trying to replace font Arial with Calibri on multiple docx files on folders+subfolders.
This code I found it's not working on subfolders.
Can anyone, please, help to add this part?
Code:
Sub BatchReplaceFont()
  Dim objDoc As Document
  Dim objSingleWord As Range
  Dim strFile As String, strFolder As String
 
  strFolder = "C:\Users\Test\Desktop\test files\"
  strFile = Dir(strFolder & "*.docx", vbNormal)
 
  While strFile <> ""
  Set objDoc = Documents.Open(FileName:=strFolder & strFile)
 
  For Each objSingleWord In objDoc.Words
    If objSingleWord.Font.Name = "Arial" Then
      objSingleWord.Font.Name = "Calibri"
    End If
  Next objSingleWord
 
  objDoc.Save
  objDoc.Close
  strFile = Dir()
  Wend
End Sub
Reply With Quote