View Single Post
 
Old 04-18-2023, 06:33 AM
savvy savvy is offline Windows 10 Office 2019
Novice
 
Join Date: Aug 2020
Location: Toronto
Posts: 23
savvy is on a distinguished road
Default if next key pressed is "del"

The macro is below. It highlights the next set of square brackets when I press + (the closest key to the mouse which was free to reassign). Essentially, it replaces Dragon Dictate verbal commands which require me to turn on the mic when I prefer to keep it off and talk while editing).

If I want to change the text that is highlighted I type in the change, press + and go to the next set of [].

If I want to keep the default text I press + and go to the next set of [....default text].

If I want to delete highlight and move on to the next set of [] want to add code that will: If the next key pressed is "del" press "del" and run the macro again (to continue to the next set of [].

this is my code:
Sub FindBetweenSqBrac()
'
' FindBetweenSqBrac Macro
'
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "(\[)(*)(\])"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute

End Sub

Thank you.
Reply With Quote