Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 04-18-2023, 05:24 PM
Guessed's Avatar
Guessed Guessed is offline if next key pressed is "del" Windows 10 if next key pressed is "del" Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,185
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

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
Reply With Quote
 



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
if next key pressed is "del" 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
if next key pressed is "del" How to choose a "List" for certain "Heading" from "Modify" tool? Jamal NUMAN Word 2 07-03-2011 03:11 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:47 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