View Single Post
 
Old 04-20-2023, 01:26 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 delete

Thanks. I had already considered your approach. The problem is that it slows down the work when there are many [default text] in the document

would this work?

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

If the next key pressed is {DEL}
then
SendKeys {DEL}
play FindBetweenSqBrac Macro
OR if the next key pressed is anything else than {DEL}
then
End Sub

Or would reassigning keypresses work? for example:

run FindBetweenSqBrac Macro 'same code as macro above
then
assign {DEL} to "{DEL} and run FindBetweenSqBrac macro"
then
assign {DEL} back to {DEL}
End Sub

Thanks again
Savvy
Reply With Quote