Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-28-2023, 08:43 AM
davidvargas72 davidvargas72 is offline Find-and-Replace Special Characters Windows 10 Find-and-Replace Special Characters Office 2021
Novice
Find-and-Replace Special Characters
 
Join Date: Jan 2023
Posts: 6
davidvargas72 is on a distinguished road
Default

Another issue. I'm using wildcards in the script but it's not working, see below. I've added MatchWildcards:=True, _ runs without errors but replaces with actual characters.

Sub Punctuation()

Dim vFindText As Variant
Dim vReplaceText As Variant


Dim oRng As Range
Dim i As Long
vFindText = Array(":^tSO ", ". SO ", "? SO ", "WORKERS COMPENSATION", "WORKERS COMP", "WORKER'S COMPENSATION", "WORKER'S COMP")
vReplaceText = Array(":^tSO, ", ". SO, ", "? SO, ", "WORKERS' COMPENSATION", "WORKERS' COMP", "WORKERS' COMPENSATION", "WORKERS' COMP")
For i = 0 To UBound(vFindText)
Set oRng = ActiveDocument.Range
With oRng.Find
.ClearFormatting
.Replacement.ClearFormatting
Do While .Execute(findText:=vFindText(i), _
MatchWholeWord:=True, _
Forward:=True, _
MatchWildcards:=True, _
Wrap:=wdFindStop) = True
oRng.Text = vReplaceText(i)
oRng.Collapse wdCollapseEnd
Loop
End With
Next
lbl_Exit:
Set oRng = Nothing
Exit Sub
End Sub
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Find-and-Replace Special Characters Find/Replace text longer than 255 characters alex100 Word VBA 5 07-08-2020 04:14 AM
Find-and-Replace Special Characters Combining Characters in Find & Replace Surge Word 6 03-10-2020 12:42 AM
Find-and-Replace Special Characters multiple find and replace in vba for special words kvnrao Word VBA 7 11-02-2018 06:28 PM
Find-and-Replace Special Characters Search and Replace special characters between word using wildcards mauuuuu5 Word 1 08-23-2015 09:20 PM
Find-and-Replace Special Characters Find and Replace some characters with Bullets kjxavier Word 1 01-02-2015 12:15 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:15 PM.


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