Sub x_SearchAndReplace_MultipleFiles_Folders_Subfolders() Dim FSO As Object Dim ROOT As Object Dim fldr As Object Const strFolder = "C:\Trial\" Set FSO = CreateObject("scripting.filesystemobject") If Not FSO.folderexists(strFolder) Then MsgBox "Folder '" & strFolder & "' not found - Exiting routine", , "Error" Exit Sub End If Set ROOT = FSO.getfolder(strFolder & "\") processFolder ROOT.path For Each fldr In ROOT.subfolders processFolder fldr.path & "\" Next End Sub Sub processFolder(strFolder As String) Dim strFile As String Dim doc As Document Dim rng As Word.Range Dim fileSet As Object strFile = Dir$(strFolder & "*.docx") Do Until strFile = "" Set doc = Documents.Open(strFolder & strFile) For Each rng In doc.StoryRanges With rng.Find .ClearFormatting .Replacement.ClearFormatting .Text = "15.500" .Replacement.Text = "19.500" .Replacement.Font.Size = 9 .Forward = True .Wrap = wdFindContinue .Execute Replace:=wdReplaceAll End With Next rng doc.Save doc.Close strFile = Dir$() Loop End Sub
Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.
When asked, what has been your best career decision?
Deciding to stick with EE.
Being involved with EE helped me to grow personally and professionally.
An Experts Exchange subscription includes unlimited access to online courses.Get Started
Connect with Certified Experts to gain insight and support on specific technology challenges including:
We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE