I want to create a macro that will find and replace text (example: putting a hard space after a number) but requesting a Yes/No selection with each one it encounters rather than an automatic replace since not all of the encounters will be changed. How
can I do that?
Ah! You are moving the goal post after the start of the game ;-)
Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim oRng As Word.Range
Set oRng = ActiveDocument.Range
With oRng.Find
.Text = "[0-9]{1,} "
.MatchWildcards = True
.Wrap = wdFindStop
While .Execute
oRng.Select
Select Case MsgBox("Replace with hard non-breaking space?", vbYesNoCancel, "FOUND")
Case vbYes
oRng.Characters.Last = Chr(160)
Case vbCancel
Exit Sub
Case Else: 'No nothing
End Select
oRng.Collapse wdCollapseEnd
Wend
End With
End Sub
Greg Maxey *** Death smiles at us all, but all a man can do is smile back.
For more help with Word visit: http://gregmaxey.com/word_tips.html
Was this reply helpful?
Sorry this didn't help.
Great! Thanks for your feedback.
How satisfied are you with this reply?
Thanks for your feedback, it helps us improve the site.