![]() |
|
#1
|
|||
|
|||
|
Much pretty sure about getting solution from this forum!
Got a code, and the code needs execution so that the pointed folder, containing Word files, completely 'Find and Replace' the files' content in whole. Much obliged if the below code gets optimized too (quick execution)! Below is the F/R code: Code:
Sub FindAndReplaceMultiItems()
Dim strFindText As String
Dim strReplaceText As String
Dim nSplitItem As Long
Application.ScreenUpdating = False
strFindText = "northenn,westenn"
strReplaceText = "northern,western"
nSplitItem = UBound(Split(strFindText, ","))
' Find each item and replace it with new one respectively.
For nSplitItem = 0 To nSplitItem
With Selection
.HomeKey Unit:=wdStory
With Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = Split(strFindText, ",")(nSplitItem)
.Replacement.Text = Split(strReplaceText, ",")(nSplitItem)
.Format = False
.MatchWholeWord = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End With
Next nSplitItem
Application.ScreenUpdating = True
MsgBox "DONE EXECUTION"
End Sub
Last edited by Leslie; 03-01-2020 at 11:07 AM. Reason: added description |
| Tags |
| macro, multiple find and replace |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Static Folder Locations to Automate a Find and Replace using Word VBA
|
rmoyar | Word VBA | 9 | 01-29-2020 02:35 PM |
| Need to find/replace text in many word files - but text is in embedded word files | semple.13 | Word VBA | 5 | 11-03-2015 01:20 PM |
Find & replace footer text in a folder of Word 2010 documents
|
kennethc | Word | 3 | 03-28-2015 02:49 AM |
VBA Batch Find & Replace for all MSOffice extensions, to replace File Name and Content of the File
|
QA_Compliance_Advisor | Word VBA | 11 | 09-11-2014 11:51 PM |
| Macro to replace SSN in all files within a folder | caj1980 | Word VBA | 7 | 09-11-2014 04:17 PM |