![]() |
|
#4
|
||||
|
||||
|
The simplest way is to use a MsgBox to ask if the user wants to continue on to the next location. You can click Yes (or type Y) to find next or No (or type N) to stop the macro. If you want to change the text, you type N to end the macro, make the desired change and then start the macro again.
Code:
Sub FindNextSquareBrackets()
Dim iResp As Integer, aRng As Range
Set aRng = ActiveDocument.Range(Selection.Range.Start, ActiveDocument.Range.End)
With aRng.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "(\[)(*)(\])"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
Do While .Execute
aRng.Select
iResp = MsgBox("Goto Next?", vbYesNo, "Found one")
If iResp = vbNo Then Exit Sub
aRng.Collapse Direction:=wdCollapseEnd
aRng.End = ActiveDocument.Range.End
Loop
End With
End Sub
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Mailto Hyperlink Formula contains too large of "Body" receiving "#Value" need to find workaround | MCamera | Excel | 1 | 03-02-2022 07:52 PM |
| Excel 2003: VBA "Function" causes "#VALUE!" errors after running "insert/delete row" custom macro | Matt C | Excel Programming | 2 | 01-08-2022 06:03 AM |
How to configure Word 10 so that when "enter" is pressed, the entire next line of text drops togethe
|
JKW | Word | 3 | 11-25-2015 04:55 PM |
| remove repeated words with " macro " or " wild cards " in texts with parentheses and commas | jocke321 | Word VBA | 2 | 12-10-2014 11:27 AM |
How to choose a "List" for certain "Heading" from "Modify" tool?
|
Jamal NUMAN | Word | 2 | 07-03-2011 03:11 AM |