A family of Microsoft word processing software products for creating web, email, and print documents.
Hans has given you a macro.
Here are two free Add-Ins that can do this from the user interface. Both act on one folder at a time.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi everyone,
I'm not very computer literate so bear with me.
I've got approx 150 word docs (all only 2 or 3 pages long) across 4 folders.
As an example, I've now been told that each APPLE I have in these docs, must now be written as Apple.
Is there a way I can do a "replace all" on each APPLE to become Apple - or do I need to manually open every 150 docs and do a cut and paste?
Thank you all so much in advance (please tell me it's possible or I'm going to be sitting here in front of my computer until dawn :)
Cheers,
amanda
A family of Microsoft word processing software products for creating web, email, and print documents.
Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.
Hans has given you a macro.
Here are two free Add-Ins that can do this from the user interface. Both act on one folder at a time.
Start Word so that you have a new empty document.
Press Alt+F11 to activate the Visual Basic Editor.
Select Insert > Module.
Copy the code listed below into the module.
Edit the code as indicated - you need to specify the words to be found and replaced, and the folder paths.
With the insertion point anywhere in the code, press F5 to run the code.
Switch back to Word.
If you want to keep the code for later use, save the empty document as a macro-enabled document (.docm).
You'll have to allow macros if you reopen it later.
Sub ReplaceMany()
' Change the constants as needed
Const ReplaceWhat = "APPLE"
Const ReplaceWith = "Apple"
Dim Folders As Variant
Dim Folder As Variant
Dim File As String
Dim Doc As Document
Application.ScreenUpdating = False
' Change the paths to the folders containing your documents
Folders = Array("C:\Word\Folder1", "C:\Word\Folder2", _
"C:\Word\Folder3", "C:\Word\Folder4")
' Loop through the folders
For Each Folder In Folders
' Add path separator if necessary
If Right(Folder, 1) <> Application.PathSeparator Then
Folder = Folder & Application.PathSeparator
End If
' Get first file name
File = Dir(PathName:=Folder & "*.doc*")
' Loop through the files
Do While File <> ""
' Open document
Set Doc = Documents.Open(FileName:=Folder & File, AddToRecentFiles:=False)
' Replace text
Doc.Content.Find.Execute FindText:=ReplaceWhat, MatchCase:=True, _
MatchWholeWord:=True, ReplaceWith:=ReplaceWith, Replace:=wdReplaceAll
' Save and close document
Doc.Close SaveChanges:=True
' Get the next file name
File = Dir
Loop
Next Folder
Application.ScreenUpdating = True
End Sub
See, for example: https://www.msofficeforums.com/159681-post25.html. By running the 'Main' macro there, all files in a given folder and its sub-folders will be processed. The actual find/replace expressions go in the Update(Rng As Range) sub.