Help with Selection VBA
Hi guys
I'm writing a code for the typists at our company to use. This one in particular just searches for double spaces and asks to convert them to a single space. It cycles through each instance it finds, asking if you want to change it to a single space.
The first instance shows the selection it found, but when it cycles to the next instance it finds it is not showing as selected -- although it still corrects the double space, it just doesn't select the area; I want it to show the selection, so users know what they're correcting. Thoughts?
Sub StyleCheck_DoubleSpaces_Test()
Selection.HomeKey Unit:=wdStory
Dim oFound As Boolean
oRange = Selection.Text
oSearch = Selection.Find.Found
With Selection.Find
oFound = .Execute
While oFound
With oRange
With oSearch
Dim Result As Integer
Result = MsgBox("Amend selection to single space?", vbQuestion + vbOKCancel)
If Result = vbCancel Then Exit Sub
With ActiveDocument.Content.Find
oFound = .Execute(FindText:=" ", Forward:=True, Wrap:=wdFindStop, ReplaceWith:=" ", Replace:=wdReplaceOne)
End With
End With
End With
Wend
End With
End Sub
|