View Single Post
 
Old 11-17-2020, 05:17 AM
JamesWood JamesWood is offline Windows 10 Office 2019
Advanced Beginner
 
Join Date: Nov 2020
Posts: 37
JamesWood is on a distinguished road
Default

Hi Greg


Leading on from this, I am making another version that searches for contractions. However, how can I make it search without matchcase, but replace WITH matchcase? e.g. if it finds "Can't" I want it to replace it with Cannot, not cannot.


Sub StyleCheck_ContractionsTest()
Dim oRng As Range
Set oRng = ActiveDocument.Range
Selection.HomeKey Unit:=wdStory
With oRng.Find
.Text = "can't"
.MatchCase = False
.Wrap = wdFindStop
While .Execute
oRng.Select
If MsgBox("Do you want to amend the selected contraction?", vbYesNo, "Conver") = vbYes Then
oRng.Text = "cannot"
oRng.Collapse wdCollapseEnd
End If
Wend
End With
MsgBox ("Complete!")
lbl_Exit:
Exit Sub
End Sub
Reply With Quote