Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 06-07-2022, 01:28 AM
w64bit w64bit is offline Replace font (multiple files) Windows 8 Replace font (multiple files) Office 2013
Novice
Replace font (multiple files)
 
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
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Replace font (multiple files) Replace or apply new header in multiple files Carchee Word VBA 42 07-10-2024 08:47 AM
Replace font (multiple files) Replace lines of text from header in multiple files PolarPop Word VBA 6 05-27-2022 01:43 PM
Replace all Images with ordinal numbers in multiple files beginner Word 0 09-19-2021 02:19 AM
Find and replace header text across multiple files LG1972 Excel 1 12-25-2018 04:27 AM
Replace font (multiple files) Macro to Find & Replace Font formats for Multiple Values GemBox Word 6 03-12-2018 05:24 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:33 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft